I am trying to read host names from a file line by line and at the same time resolve each dns name to its IP address. I am using this very simple code:

```
import socket

path = "C:\Domain\domains.txt"

f = open(path, 'r')

for line in f:
    print socket.gethostbyname(line)

```

But I get this error:

```
Traceback (most recent call last):
  File "C:\resolve.py", line 8, in <module>
    print socket.gethostbyname(line)
gaierror: [Errno 11004] getaddrinfo failed

```

I did some reading and it looks like the reason for the failure is the \n carriage return. 
I tried to strip the \n in a few ways but it did not work. Can you pls help with this? 

Thank You.