title: How to write output of terminal to file
body: <p>I want to save result of script to file. Example of script:</p>
  
  <pre><code>#!/usr/bin/env python
  i=0
  while i&lt;10:
    a=raw_input('Write a number')
    print 'Result%s'%str(2*a)
    i+=1
  </code></pre>
  
  <p>And I want to save to file print value. I know that I can do that in script <code>f=open()...</code>, but I want to do that using output in terminal. I read that I can use module <code>subprocess</code> but I don't know it is correct.</p>