title: Issues writing beautifulsoup output to .txt
body: <p>I am scraping web articles with beautifulsoup. The output is printing correctly, but is not writing the complete output to the file. It seems to break once it hits a quoted sentence. Below is the relevant code. Any insights would be tremendously helpful. </p>
  
  <p>Use this URL to replicate the results: <a href="http://www.reuters.com/article/2014/03/06/us-syria-crisis-assad-insight-idUSBREA250SD20140306" rel="nofollow">http://www.reuters.com/article/2014/03/06/us-syria-crisis-assad-insight-idUSBREA250SD20140306</a></p>
  
  <pre><code>import urllib2
  from bs4 import BeautifulSoup
  import re
  import codecs
  
  # Ask user to enter URL
  url = raw_input("Please enter a valid URL: ")
  
  # Make sure file is clear for new content
  open('ctp_output.txt', 'w').close()
  
  # Open txt document for output
  txt = open('ctp_output.txt', 'w')
  
  # Parse HTML of article, aka making soup
  soup = BeautifulSoup(urllib2.urlopen(url).read())
  
  # retrieve all of the paragraph tags
  with open('ctp_output.txt', 'w'):
      for tag in soup.find_all('p'):
          txt.write(tag.text.encode('utf-8') + '\n' + '\n')
  
  # Close txt file with new content added
  txt.close()
  </code></pre>