bash: ssh with sudo a different user and launch shell

I want to ssh with a different user and launch shell. The first command I try is below,

$ ssh -t -q host "sudo -S -i -u user" 2>&1
[sudo] password for user:
[user@host ~]$ 

which works fine. Then I try a file for password, the command exits immediately.

$ ssh -t -q host "sudo -S -i -u user" <password.txt 2>&1

I want the second command to behave like the first one, i.e., use file instead of typing password while remain in the bash.