title: I'm getting the following error and can't work it out
body: <p>I'm learning Python and started putting together the below code. I'm trying to get the <code>fread</code> function working correctly but I'm getting an error.</p>
  
  <p>I've tried a few ways to fix it but of course if I don't know what's causing it I'm never going to fix it.</p>
  
  <p>I'm hoping someone could help me out.</p>
  
  <p><strong>Error</strong></p>
  
  <pre><code>unknown@ubuntu:~$ ./attack.py -f wordfile.txt
  Traceback (most recent call last):
    File "./attack.py", line 63, in &lt;module&gt;
      print fread(list)
    File "./attack.py", line 20, in fread
      flist = open(list).readlines()
  TypeError: coercing to Unicode: need string or buffer, type found`
  </code></pre>
  
  <p><strong>CODE</strong></p>
  
  <pre><code>#!/usr/bin/python
  
  
  import sys, getopt, socket, fileinput, traceback
  import dns.query, dns.message, dns.name, adns
  from Queue import Queue
  from threading import Thread
  
  
  def usage():
      print "-h --help: help\n"
      print "-f --file: File to read bruteforce domain list from.\n"
      print "-p --proxy: Proxy address and port. e.g http://192.168.1.64:8080\n"
      print "-d --domain: Domain to bruteforce.\n"
      print "-t --thread: Thread count.\n"
      print "-e: Turn debug on.\n"
      sys.exit()
  
  def fread(list, *args):
     flist = open(list).readlines()
     return flist
  
  def addcheck(fcontent):
     data =[]
     c=adns.init()
     for sub in file:
       SubDomain = fcontent + domain
       data[SubDomain] = c.synchronous(SubDomain, adns.rr.A)
     return data
  
  
  def main(argv):
    list = None
    proxy = None
    domain = None
    FILE= None
    try:
       opts, argv =getopt.getopt(argv, "h:f:p:d:t:e",["help", "file=", "proxy=", "domain=", "thread="])
  
    except getopt.GetoptError as err:
      print str(err)
      usage()
      sys.exit(2)
  
    for opt, arg in opts:
        if opt in ("-h", "--help"):
            usage()
            sys.exit()
        elif opt in ("-f", "--file"):
            list = arg
        elif opt in ("-p", "--proxy"):
            proxy = arg
        elif opt in ("-d", "--domain"):
            domain = arg
        elif opt in ("-t", "--thread"):
            thread = arg
        elif opt in '-e':
            global _debug
  
  print fread(list)
  if __name__ == "__main__":
     main(sys.argv[1:])
  </code></pre>