SFTP to server through Shell Script

I am sftp-ing to a server through a shell script from my local machine.

sftp user@host
put out.txt
bye

On executing the script, it prompts to enter the password, and after giving the password it successfully connects to the host.But the problem is that the remaining statements after the connection statement(in line1) are not getting executed.The out.txt is the file I want to put in the sever, then disconnect..

How can I achieve this through a shell script program?

check this link , Please search this forum before posting a thread.