title: Writing to a file but getting ASCII encoding error
body: <p>I am trying to scrape data from a table on a website. </p>
  
  <pre><code>page_soup = soup(html, 'html.parser')
  stat_table = page_soup.find_all('table')
  stat_table = stat_table[0]
  
  with open ('stats.txt','w') as q:
  for row in stat_table.find_all('tr'):
      for cell in row.find_all('td'):
          q.write(cell.text)
  </code></pre>
  
  <p>However, when I try to write the file, I get this error message: 'ascii' codec can't encode character '\xa0' in position 19: ordinal not in range(128).</p>
  
  <p>I understand that it should be encoded with .encode('utf-8'), but </p>
  
  <pre><code>cell.text.encode('utf-8')
  </code></pre>
  
  <p>doesn't work. </p>
  
  <p>Any help would be greatly appreciated. Using Python 3.6 </p>