title: Avoid writing carriage return '\r' when writing line feed with Python
body: <p>If taken into consideration that <code>carriage return = \r</code> and <code>line feed = \n</code></p>
  
  <pre><code>Python 3.5.1 (v3.5.1:37a07cee5969, Dec  6 2015, 01:38:48) [MSC v.1900 32 bit (Intel)] on win32
  Type "help", "copyright", "credits" or "license" for more information.
  &gt;&gt;&gt; '{:02x}'.format(ord('\n'))
  '0a'
  &gt;&gt;&gt; '{:02x}'.format(ord('\r'))
  '0d'
  </code></pre>
  
  <p>how to avoid writing carriage return when using <code>open('filename','w').write('text\n')</code> ?</p>
  
  <p>In interactive mode you can do this:</p>
  
  <pre><code>&gt;&gt;&gt; open('filename','w').write('text\n')
  5
  &gt;&gt;&gt; for c in open('filename','r').read():
  ...     print('{:02x}'.format(ord(c)))
  ...
  74
  65
  78
  74
  0a
  </code></pre>
  
  <p>This would indicate that only line feed has been written, thus it should be 5 bytes long.</p>
  
  <pre><code>-rw-r--r-- 1 djuric 197121        6 Jul 15 21:00 filename
                                    ^
  </code></pre>
  
  <p>It is actually 6 bytes long. Now this can be a "Windows thing", but when you open the file in Notepad++ for example, and you turn <strong>View > Show Symbols > Show All Characters</strong> you can see the carriage return there.</p>
  
  <p>After pressing CTRL+H and replacing \r with nothing using Extended Search Mode, only line feed is left. After saving the file, only line feed is in the file and the file is 5 bytes long.</p>
  
  <pre><code>-rw-r--r-- 1 djuric 197121    5 Jul 15 20:58 filename1
                                ^
  </code></pre>
  
  <p>So why is Notepad++ able to save line feeds without carriage return, but python can't?</p>