title: Extract text from .html file, remove HTML, and write to text file using Python and Beautiful Soup
body: <p>I'm using Beautiful Soup 4 to extract text from HTML files, and using <code>get_text()</code> I can easily extract just the text, but now I'm attempting to write that text to a plain text file, and when I do, I get the message "416." Here's the code I'm using:</p>
  
  <pre><code>from bs4 import BeautifulSoup
  markup = open("example1.html")
  soup = BeautifulSoup(markup)
  f = open("example.txt", "w")
  f.write(soup.get_text())
  </code></pre>
  
  <p>And the output to the console is <code>416</code> but nothing gets written to the text file. Where have I gone wrong?</p>