I just went through this procedure 5 times:
ssh to my DH site
start editing the file
BOOM! connection closed by remote host.
try again, vi offers to recover the file, say yes, start editing again… BOOM! connection closed by remote host.
I got there in the end, but it was quite annoying.
I should find a decent sftp client I suppose