title: perl appending issues
body: <p>I have some code that appends into some files in the nested for loops. After exiting the for loops, I want to append .end to all the files.</p>
  
  <pre><code>foreach my $file (@SPICE_FILES)
  {
      open(FILE1, "&gt;&gt;$file") or die "[ERROR $0] cannot append to file : $file\n";
      print FILE1 "\n.end\n";
      close FILE1; 
  }
  </code></pre>
  
  <p>I noticed in some strange cases that the ".end" is appended into the middle of the files!</p>
  
  <p>how do i resolve this??</p>