title: Python read from file and remove non-ascii characters
body: <p>I have the following program that reads a file word by word and writes the word again to another file but without the non-ascii characters from the first file.</p>
  
  <pre><code>import unicodedata
  import codecs
  infile = codecs.open('d.txt','r',encoding='utf-8',errors='ignore')
  outfile = codecs.open('d_parsed.txt','w',encoding='utf-8',errors='ignore')
  
  
  for line in infile.readlines():
      for word in line.split():
          outfile.write(word+" ")
      outfile.write("\n")
  
  infile.close()
  outfile.close()
  </code></pre>
  
  <p>The only problem that I am facing is that with this code it does not print a new line to the second file (d_parsed). Any clues??</p>