When copying a file, via scp get, to an existing local file that is larger then the remote file, the copy does not complete. The larger local file is never replaced. I was able to get around this by always deleting the local file [File.Delete(lfile)] in the line before your [filestream write(lfile)].