Nslookup on a variable inside script not working

I am new at scripting. I have a file that each line is the shortname for a server.
ie -
Server1
Server2
Server3
I want to read in that file, do a nslookup and print the FQDN to a file.
I added an echo statement to make sure my variable was being read and changing. But the nslookup returns nothing.

** code below should just display the FQDN, I took out the writing to a file for now.

#!/bin/ksh
#
# Variables
#
Ifile=/home/khowe/ServerNames.txt
OFile=/home/khowe/FullName.txt
#
while read name kaka
  do
#    nslookup ${name} |grep Name | awk {'print $2'} >> ${OFile}
    echo ${name}
    nslookup ${name} |grep Name
  done < ${Ifile}

You've told us what it doesn't do, what does it do?

Sorry.. that probably would of helped. the echo ${name} proves the servers are being read. They are displayed and changing.

I can take this snipped

nslookup ${name} |grep Name

add

nslookup Server1 |grep Name

Output will display Server1.mydomain.com

I can take that code inside the loop and run it line by line and it works.

name = server1
 nslookup ${name} |grep Name

output is server1.mydomain.com

code doesn't appear to want to work with the nslookup on the variable inside the loop.

Please become accustomed to provide decent context info of your problem.
It is always helpful to support a request with system info like OS and shell, related environment (variables, options), preferred tools, adequate (representative) sample input and desired output data and the logics connecting the two, and, if existent, system (error) messages verbatim, to avoid ambiguities and keep people from guessing.

You seem to have difficulties with upper and lower case S . Are you sure the correct name is in the input file?

Try:

 nslookup ${name} | grep ${name}
 

nslookup will return the literal string Name in its output, so the original command should be fine (although grep -o on Linux would just return the name, if found) - provided either that the input file does contain fully qualified hostnames or you have defined the appropriate search domain(s) (assuming the hosts you're looking up are yours *).

What's the contents of the actual input file and your /etc/resolv.conf? *