title: Python gives unicode error when writing to file
body: <p>I'm trying to write to a file.</p>
  
  <pre><code>filename = "test.txt"
  string = "Niñas and niños"
  
  with open(filename, 'w') as element:
              element.write(string)
  </code></pre>
  
  <p>This returns the following error:</p>
  
  <pre><code>"Traceback (most recent call last):
    File "/Users/alex/Documents/Python/filewriter.py", line 5, in &lt;module&gt;
      element.write(string)
  UnicodeEncodeError: 'ascii' codec can't encode character '\xf1' 
  in position 2: ordinal not in range(128)"
  </code></pre>
  
  <p>I am using the latest version of Python, latest version of MacOS, and SublimeText3 as my editor.</p>
  
  <p>Anyone have an idea what's going on?</p>