You can read each line from a file provided as first command-line argument with read
in combination with a while-loop. Provided that the file contains an ip address on each line:
while read ip; do
echo -n "$ip "
echo '! U1 getvar "appl.name"' | nc -i2 $ip 5964 > doc
done < "$1"