title: Python, return IP address of list of urls
body: <p>I am trying to automate a task with Python where a have a .txt file list of urls and converts it to a .txt file list of IP addresses. Domain.txt has an active url on each line, and IP.py is as follows:</p>
  <pre><code>import socket
  
  urls = open('domain.txt', 'r')
  
  for lines in urls:
      IP = socket.gethostbyname(lines)
  print(IP)
  </code></pre>
  <p>I am running this script wrong by calling it with:</p>
  <pre><code>$ python3 IP.py domain.txt
  </code></pre>
  <p>What is proper syntax for this script?</p>
  <p>The output error I am getting is:</p>
  <pre><code>Traceback (most recent call last):
    File &quot;IP.py&quot;, line 6, in &lt;module&gt;
      IP = socket.gethostbyname(lines)
  socket.gaierror: [Errno -5] No address associated with hostname
  </code></pre>