title: File object has no attribute encode- BeautifulSoup and Python
body: <p>I'm trying to figure out the best way to parse a HTML file and make sure I'm dealing with entirely in utf-8 format. Currently I have:</p>
  
  <pre><code>fileName = open(givenDir +"/"+ aFile, "r").encode('utf8')
  soup = BeautifulSoup(fileName)
  </code></pre>
  
  <p>And I continue on my way. These are all local files. But it says that file object has no attribute encode. If I take out the encode bit, it all works fine, however when I go to print out letters with the following bit of code:</p>
  
  <pre><code>for word, count in wordList:
      wordFile.write("%s: %d\n" % (word.encode('utf8'), count))
  </code></pre>
  
  <p>A message comes up with "Warning:root:Some characters could not be decoded, and were replaced with REPLACEMENT CHARACTER", which leads me to believe nothing was really encoded properly to begin with?</p>
  
  <p>Can anyone clarify this for me?</p>