title: sockect.gethostbyaddr in a for loop read from a file
body: <p>Trying to feed a text file list through socket.gethostbyaddr and I seem to be stuck on a data type issue.</p>
  
  <p>when try to loop through the list I'm getting no output except an Exception error on my last test line</p>
  
  <p>This is just a small script to resolve ip to name if one exists.  To test my opened file is just:</p>
  
  <pre><code>1.1.1.1
  2.2.2.2
  10.1.1.1
  </code></pre>
  
  <p>with my local hosts having an entry for the first two lines to a "test1"or "test2" name</p>
  
  <p>just running socket.gethostbyaddr('1.1.1.1') returns "test1" as the host so I know that part is correct for testing</p>
  
  <pre><code>import subprocess
  import socket
  tstout = open('testout.txt','w+')
  with open("testip.txt", "r") as ins:
      for l in ins:
          line = str(l)
      try:
          tstout.write (socket.gethostbyaddr(line))
      except Exception as e:
          print (e)
  tstout.close()
  subprocess.Popen([r'c:\Windows\notepad.exe',r'c:\scripts\testout.txt'])
  </code></pre>
  
  <p>Was expecting the output file to have the resolve results written to it, any pointers where I messed this up is appreciated</p>
  
  <p>Simplified to:</p>
  
  <pre><code>import socket
  tstout = open('testout.txt','w+')
  with open("testip.txt", "r") as ins:
      for l in ins:
          l = str(l)
  #        print(l)
          tstout.write (socket.gethostbyaddr(l))
  </code></pre>