Think it over: when you do a "ssh machine command", then "command" will be executed on the remote host, not your local one. If "command" is something like "for x in $(cat file) ...", then you are referring to a remote file, not a local one!
if you want to process a file locally and start ssh-sessions remotely using the content of the file you have to do the loop locally. The following sketch shows how:
while read LINE ; do
ssh user@host "do_something_with $LINE"
done < /path/to/some/file
A second problem is your use of double quotes. You see, a shell maintains a simple switch "inside/outside a double quote" and once it encounters such a character this switch is flipped. Therefore double quotes cannot be nested. You will have to escape the inner pair to make your command work:
ssh root@IPaddress "IFS=$'\n'; for i in $(cat file) ;do echo \"HI $i\" ; done"
(which will - as explained above - still not work, but for a different reason)