SFTP: make it so files can be downloaded into resources or upload from resources

Fixes #428
Add a new variable $need_to_close_fp or so for this statement.