This will only loop once even if the file has multiple lines, since ssh is reading stdin attached to the whole loop and forwards it to the stdin of the "hostname" command executed on the remote host (which happily discards it, not reading from stdin at all).