fixing zero length packet handling and making remote to host copy write to a file