The output for the password prompt goes to stderr, not stdout. I don't have time to get a fix working but hopefully this points you in the right direction.
JK
Update:
The comment about the newline was right. Add a \n in the send and things should be ok.