Re: Error handling
                You need to use 
https://winscp.net/eng/docs/scriptcommand_option
Even better, use
https://winscp.net/eng/docs/scriptcommand_get
        option batch abort at the start of the script.
https://winscp.net/eng/docs/scriptcommand_option
Even better, use
-delete switch with the get command, instead of rm command.
https://winscp.net/eng/docs/scriptcommand_get