Returns true if the current text file is pointing at a line end System unit
 function Eoln(var FileHandle TextFile):Boolean;
The Eoln function returns true if the current file given by FileHandle is positioned at the end of the current line.
The file must have been assigned using AssignFile, and opened with Reset.
The Eoln function is used with the Read procedure to know when the end of the current line has been reached.
More specifically, it is only needed when reading character data - reading numeric data treats the end of line as white space, and skips past it when looking for the next number.
Warning after reading the last line of a file, Eof will be true, even though data has been read successfully.

So use Eof before reading, to see if reading is required.
Related commands
EofReturns true if a file opened with Reset is at the end
ReadRead data from a binary or text file
ReadLnRead a complete line of data from a text file
SeekEofSkip to the end of the current line or file
SeekEolnSkip to the end of the current line or file
 Download this web site as a Windows program.

Example code : Reading one character at a time from a text file line
  myFile : TextFile;
  letter : char;
  text   : string;

  // Try to open the Test.txt file for writing to
  AssignFile(myFile, 'Test.txt');

  // Write lines of text to the file
  WriteLn(myFile, 'Hello');
  WriteLn(myFile, 'To you');

  // Close the file

  // Reopen the file for reading

  // Display the file contents
  while not Eof(myFile) do
    // Proces one line at a time
    ShowMessage('Start of a new line :');
    while not Eoln(myFile) do
      Read(myFile, letter);  // Read and display one letter at a time
    ReadLn(myFile, text);

  // Close the file for the last time
Show full unit code
  Start of a new line :
  Start of a new line :
Delphi Programming © Neil Moffatt . All rights reserved.  |  Home Page