title: append subprocess.Popen output to file?
body: <p>I can successfully redirect my output to a file, however this appears to overwrite the file's existing data:</p>
  
  <pre><code>import subprocess
  outfile = open('test','w') #same with "w" or "a" as opening mode
  outfile.write('Hello')
  subprocess.Popen('ls',stdout=outfile)
  </code></pre>
  
  <p>will remove the <code>'Hello'</code> line from the file.</p>
  
  <p>I guess a workaround is to store the output elsewhere as a string or something (it won't be too long), and append this manually with <code>outfile.write(thestring)</code> - but I was wondering if I am missing something within the module that facilitates this.</p>