title: write the screen output into the file
body: <p>I got a question about redirect the screen output into a single file. Here is my code to print the screen output:</p>
  
  <pre><code>for O,x,y,z,M,n in coordinate:
      print(O,x,y,z,M,n)
  </code></pre>
  
  <p>And the screen output looks like: </p>
  
  <pre><code>O 0 0 0 ! 1
  O 1 0 0 ! 2 
  O 2 0 0 ! 3
  </code></pre>
  
  <p>So how can I redirect all the data into a single file and in the same format, just like the screen output. Because it will be mush faster to get all the data rather than waiting for the screen output to finish.
  I tried<code>for point in coordinate:
          file.write(' '.join(str(s) for s in point))</code> but output file became:</p>
  
  <pre><code>O 0 0 0 ! 0O 1 0 0 ! 1O 2 0 0 ! 2O 3 0 0 ! 3O 4 0 0 ! 4O 5 0 0 ! 5O 6 0 0 ! 6O
  </code></pre>