Sed subsitution on loop output in shell script

I have a forloop which checks a log for a set of 6 static IP addresses and each IP found is logged to a file which is then mailed to me.

After the forloop I always have a text file that may contain up to 6 IP addresses or may contain 0.
What I want to do is substitute the IP addresses (if any) into their hostnames so that the mail is more readable.

I was trying to use sed to accomplish this but i was having trouble getting the right result.
Any tips on how to do this or is sed even the best tool to use?

Thanks

How about something like:

for i in `cat file`
   do
       nslookup ${i} "format options here" >> file.another
   done

Interesting nslookup might just do the trick, I'll give it a try.
Thanks for the suggestion.