You've got some funny characters in your file (at the end of each line). Do:
od -xcb a.txt
and post the results here. It's possible the file came from another system (DOS/Windows) although \013 is the VT character rather than CR.
When I do the same with files created from scratch, I get:
pax@pax-desktop:~$ . ./a.sh
microsoft.com
microsoft.com has address 207.46.197.32
microsoft.com has address 207.46.232.182
microsoft.com mail is handled by 10 mail.messaging.microsoft.com.
google.com
google.com has address 74.125.45.100
google.com has address 74.125.67.100
google.com has address 74.125.127.100
google.com mail is handled by 10 smtp2.google.com.
google.com mail is handled by 10 smtp3.google.com.
google.com mail is handled by 10 smtp4.google.com.
google.com mail is handled by 10 smtp1.google.com.
ibm.com
ibm.com has address 129.42.16.103
ibm.com has address 129.42.17.103
ibm.com has address 129.42.18.103
ibm.com mail is handled by 10 e4.ny.us.ibm.com.
ibm.com mail is handled by 10 e5.ny.us.ibm.com.
ibm.com mail is handled by 10 e6.ny.us.ibm.com.
ibm.com mail is handled by 10 e31.co.us.ibm.com.
ibm.com mail is handled by 10 e32.co.us.ibm.com.
ibm.com mail is handled by 10 e33.co.us.ibm.com.
ibm.com mail is handled by 10 e34.co.us.ibm.com.
ibm.com mail is handled by 10 e35.co.us.ibm.com.
ibm.com mail is handled by 10 e1.ny.us.ibm.com.
ibm.com mail is handled by 10 e2.ny.us.ibm.com.
ibm.com mail is handled by 10 e3.ny.us.ibm.com.
My od
output is:
0000000 696d 7263 736f 666f 2e74 6f63 0a6d 6f67
m i c r o s o f t . c o m \n g o
155 151 143 162 157 163 157 146 164 056 143 157 155 012 147 157
0000020 676f 656c 632e 6d6f 690a 6d62 632e 6d6f
o g l e . c o m \n i b m . c o m
157 147 154 145 056 143 157 155 012 151 142 155 056 143 157 155
0000040 000a
\n \0
012 000
0000041
Have a look at the od
output for your file and see if there's anything before the \n
characters.
Update:
From your comment, it appears your file was created under DOS/Windows since it has a CR/LF line ending. Use this as the script to strip out CR charcters first:
#!/bin/sh
for j in `cat a.txt`
do
i=`echo $j | sed 's/\r//g'`
echo $i
host $i
done