title: How to write the output to html file with Python BeautifulSoup
body: <p>I modified an html file by removing some of the tags using <code>beautifulsoup</code>. Now I want to write the results back in a html file.
  My code:</p>
  
  <pre><code>from bs4 import BeautifulSoup
  from bs4 import Comment
  
  soup = BeautifulSoup(open('1.html'),"html.parser")
  
  [x.extract() for x in soup.find_all('script')]
  [x.extract() for x in soup.find_all('style')]
  [x.extract() for x in soup.find_all('meta')]
  [x.extract() for x in soup.find_all('noscript')]
  [x.extract() for x in soup.find_all(text=lambda text:isinstance(text, Comment))]
  html =soup.contents
  for i in html:
      print i
  
  html = soup.prettify("utf-8")
  with open("output1.html", "wb") as file:
      file.write(html)
  </code></pre>
  
  <p>Since I used soup.prettify, it generates html like this:</p>
  
  <pre><code>&lt;p&gt;
      &lt;strong&gt;
       BATAM.TRIBUNNEWS.COM, BINTAN
      &lt;/strong&gt;
      - Tradisi pedang pora mewarnai serah terima jabatan pejabat di
      &lt;a href="http://batam.tribunnews.com/tag/polres/" title="Polres"&gt;
       Polres
      &lt;/a&gt;
      &lt;a href="http://batam.tribunnews.com/tag/bintan/" title="Bintan"&gt;
       Bintan
      &lt;/a&gt;
      , Senin (3/10/2016).
     &lt;/p&gt;
  </code></pre>
  
  <p>I want to get the result like <code>print i</code> does:</p>
  
  <pre><code>&lt;p&gt;&lt;strong&gt;BATAM.TRIBUNNEWS.COM, BINTAN&lt;/strong&gt; - Tradisi pedang pora mewarnai serah terima jabatan pejabat di &lt;a href="http://batam.tribunnews.com/tag/polres/" title="Polres"&gt;Polres&lt;/a&gt; &lt;a href="http://batam.tribunnews.com/tag/bintan/" title="Bintan"&gt;Bintan&lt;/a&gt;, Senin (3/10/2016).&lt;/p&gt;
  &lt;p&gt;Empat perwira baru Senin itu diminta cepat bekerja. Tumpukan pekerjaan rumah sudah menanti di meja masing masing.&lt;/p&gt;
  </code></pre>
  
  <p>How can I get a result the same as <code>print i</code> (ie. so the tag and its content appear on the same line)? Thanks.</p>