title: How to write a file that is being read?
body: <p>My application reads a TextFile of floating point numbers slowly. From time to time circumstances change and the file has to be rewritten. Some example code:</p>
  
  <pre><code>procedure TAMI_Column_Selector.read_continuously (file_name: string);
  var infile: TextFile;
      f: Double;
  begin
     AssignFile (infile, file_name);
     Reset (infile);
     try
        while not EOF (infile) do
        begin
           Read (infile, f);
           process (f); // this may take quite some time, seconds or even minutes
        end; // while
     finally
        CloseFile (infile);
     end; // try..finally
  end; // read_continuously //
  </code></pre>
  
  <p>How can I write a file that is open for reading? More specifically:</p>
  
  <ol>
  <li>how can I write a file that is open for reading? </li>
  <li>how to prevent a crash when the application tries to read a file that at that moment
  is being written  </li>
  <li>how does my application know that the file has been rewritten?</li>
  </ol>
  
  <p>I think I could solve the first to questions be reading the file into memory and read that (is there a TextFile that can be written to and read from memory)? Then still remains how I can test a file has been written over.</p>
  
  <p>Anyone having an (elegant) solution to this problem?</p>
  
  <p>Thanks in advance.</p>
  
  <p>Using Delphi XE on windows 7</p>