here document not working

I tried doing

ftp myhost <<HERE
username
password
quit
HERE

but it doesnt work. Why?

When I do ftp host, I always get prompted for username, and once I type that in I get prompted for password. But when I try doing it from here document it freezes.

Have you tried searching? There are hundreds of similar threads on automating ftp.

hi reborg,

yes, I did actually search this forum and found a good answer (using ftp -i -n), so I have managed to get around this. But I am still curious as to why what I did initially did not work. I thought a here document sends input line by line to the command, so I would have expected it to work.