title: Writing to a file at once or appending a line by line - disk writes
body: <p>I'm concerned about disc drive life and I'd like to know which way takes minimum amount of writes, so the HDD/SSD won't wear out too soon:</p>
  <pre><code>with open('file.txt', 'w') as f:
      for line in lines:
          f.write(line + '\n')
  </code></pre>
  <p>or</p>
  <pre><code>with open('file.txt', 'w') as f:
      f.write('\n'.join(lines))
      f.write('\n') # just to keep the same content as in the previous example
  </code></pre>
  <p>I know HDD drivers have a flushing mechanism, so in theory, both should equally wear the drive out, but I'd like to verify my understanding by asking.</p>