Scraping HTML using Beautiful Soup
regarding 1 you can:

new_content = [c for c in old_content if c != '\n']


or simply

new_content = old_content.replace('\n', '')


Regarding 5, if your are generating anything that is nontrivial, then it will pay off to learn some template engines like Jinja2. If that is too much, then you can make a simple template in text file and use regex or even replace() to substitute generic parts:

# template
&lt;div class="some value"&gt;%FOO%&lt;/div&gt;
&lt;div class="some value"&gt;%BAR%&lt;/div&gt;


and on the python side:

values = {"%FOO%": "the foos", "%BAR%": "the bars"} 
template = open('template').read()
for k, v in values.iteritems():
    template = template.replace(k, v)
print template