As I mentioned before, read the file outside the loop. Pass the total time into the loop via a shift register (not the running time of the loop) You add the running time to the file's total time and update your display. When you exit the loop (presumably pressing a stop button) you write the contents of the total time shift register to the file, again, outside the loop.
Your use of local variables works, but is not generally looked upon as a code coding style. Shift registers and wires are the best way to control data flow.
Message Edited by Phillip Brooks on 09-08-2009 07:27 PM