title: Tcl redirect stdout to file produces no output
body: <p>Question is extension of what is answered in <a href="https://stackoverflow.com/questions/8531031/how-can-i-redirect-stdout-into-a-file-in-tcl/8532484#8532484">link</a>. While trying to use it to print output with delay, <code>cat file_name</code> on the shell doesn't display the content of the file during the delay time using <code>after</code>. Here's the code:</p>
  <pre><code>proc foo {times} { 
      while {$times &gt;0} {
          puts &quot;hello$times&quot;
          incr times -1
          after 20000
          puts &quot;hello world&quot; 
      }
  }
  proc reopenStdout {file} {
      close stdout
      open $file w        ;# The standard channels are special
  }
  
  reopenStdout ./bar
  foo 10
  </code></pre>