title: Python file.write creating extra carriage return
body: <p>I'm writing a series of SQL statements to a file using python. The template string looks like:</p>
  
  <pre><code>store_insert = '\tinsert stores (storenum, ...) values (\'%s\', ...)'
  </code></pre>
  
  <p>I'm writing to the file like so:</p>
  
  <pre><code>for line in source:
      line = line.rstrip()
      fields = line.split('\t')
      script.write(store_insert % tuple(fields))
      script.write(os.linesep)
  </code></pre>
  
  <p>However, in the resulting output, I see \r\r\n at the end of each line, rather than \r\n as I would expect. Why?</p>