The Flush procedure flushes unwritten text file data to disk.
The same effect can be achieved by closing the file. In fact, this is more likely to be effective, since Flush simply passes the flush request to the Operating System, which may in turn be doing its own buffering, and possibly caching.
Example code : Flushing after writing lines to a file
myFile : TextFile;
text : string;
begin // Try to open the Test.txt file for writing to
ReWrite(myFile); // Write a couple of well known words to this file
WriteLn(myFile, 'World'); Flush(myFile); // Close the file
CloseFile(myFile); // Reopen the file for reading
Reset(myFile); // Display the file contents
while not Eof(myFile) do
end; // Close the file for the last time