title: in tcl, how do I replace a line in a file?
body: <p>let's say I opened a file, then parsed it into lines. Then I use a loop:</p>
  
  <pre><code>foreach line $lines {}
  </code></pre>
  
  <p>inside the loop, for some lines, I want to replace them inside the file with different lines. Is it possible? Or do I have to write to another temporary file, then replace the files when I'm done?</p>
  
  <p>e.g., if the file contained </p>
  
  <pre><code>AA
  BB
  </code></pre>
  
  <p>and then I replace capital letters with lower case letters, I want the original file to contain</p>
  
  <pre><code>aa
  bb
  </code></pre>
  
  <p>Thanks!</p>