sftp $TOHOST <<RESULT
cd /inbound/
lcd /transfer
put $i
bye
RESULT
You need to close the here doc - leftmost column.
What do you mean 'kill the script' -exit early?
for i in filename1 filename2 filename3
do
sftp $TOHOST <<RESULT > logfile
cd /inbound/
lcd /transfer
put $i
bye
RESULT
# bail out on error you decide what error message "words" to find
grep -E -q -i '(error|fail|no connect )' logfile && exit 1
done