program WhileEOF;
{$APPTYPE CONSOLE}
uses SysUtils;
const cFileName = 'WhileEOF.dpr';
var F : TextFile;
s : string;
begin
if FileExists( cFileName )
then
begin
AssignFile( F, cFileName );
Reset( F );
while not Eof(F) do
begin
ReadLn(F, s);
WriteLn(s);
end;
CloseFile( F );
end
else
WriteLn( 'File ' + cFileName + ' not found!' );
end.
This example print to console the text content of WhileEOF.dpr
file using While not(EOF)
condition. If file is empty then ReadLn-WriteLn
loop is not executed.