title: Deleting contents of a file in Tcl
body: <p>I'm having some troubles deleting the contents of a text file. From what I can tell, I cannot seem to rename or delete this file and create a new one with the same name, due to permission issues with the PLM software we use. Unfortunately, I am on my own here, since no one seems to know what exactly is wrong. </p>
  
  <p>I can read and write to this file, however. So I've been looking at the <a href="http://wiki.tcl.tk/1498" rel="nofollow">seek</a> command and doing something like this:</p>
  
  <pre><code>set f [open "C:/John/myFile.txt" "a+"]
  
  seek $f 0   
  set fp [tell $f]
  
  seek $f 0 end
  set end [tell $f]
  
  # Restore current file pointer
  seek $f $fp
  
  while { $fp &lt; $end } {
      puts -nonewline $f " "
      incr fp
  }
  
  close $f
  </code></pre>
  
  <p>This seems to replace all the lines with spaces, but I'm not sure this is the correct way to approach this. Can someone give me some pointers? I'm still relatively new to Tcl.</p>
  
  <p>Thanks!</p>