Declare variables earlier so sftp download works

These variables are needed whether you're uploading or downloading, so let's declare before that if statement.