Changing
grep /$host/, (@ip) to
grep /^\w,$host$/, (@ip) should work (by requiring the pattern (the IP) to compose the entire line). Also be aware that . is a regex metacharacter (match anything but \n), and so the line above really should be
grep /\w,\Q$host\E$/, (@ip) to escape any metachars in $host.
Update Didn't see the a, ... b, ... c, ... in ip.txt at first.