title: Python 2.7 : How to constrain the delimiter of a new line to be '\n' on Windows?
body: <p>When I write into a text file within a python 2.7 script that runs on Windows the new line delimiter is <code>'\r\n'</code>, but I would like it to be <code>'\n'</code>.</p>
  <p>I have tried to use <a href="http://docs.python.org/2/library/io.html#io.open" rel="nofollow noreferrer"><code>open</code></a> with <code>newline='\n'</code>, but it raised an exception.</p>
  <pre><code>import io
  f= io.open(&quot;myfile.txt&quot;, &quot;w&quot;, newline=&quot;\n&quot;)
  f.write(”aaaaaaa”)
  f.close()
  </code></pre>