What does this sleep for? Maybe session.cmd('sync') will be more suitable here. BTW, remote.RemoteFile is an optional idea for your writing in guest.