• "You have to be very careful in your cleanup and error handling routines so that you don't leave the auto-generated batch file sitting in your working directory."

    That's why the last section of code deletes the batch file and the sftp script.