title: How to save the output into a new txt file?
body: <p>I use this code to split an unstructured text file to its tokens and output each token in one line:</p>
  
  <pre><code>with open("C:\\...\\...\\...\\record-13.txt") as f:
     lines = f.readlines()
     for line in lines:
         words = line.split()
         for word in words:
             print (word)
  </code></pre>
  
  <p>Now I want to save the output into a new text file instead of printing it, I modify the code to this:</p>
  
  <pre><code>with open("C:\\...\\...\\...\\record-13.txt") as f:
     lines = f.readlines()
     for line in lines:
         words = line.split()
         for word in words:
             file = open ("tokens.txt", "w")
             file.write (word)
             file.close()
  </code></pre>
  
  <p>but it doesn't work. Would you please tell me what's wrong with that?</p>