Reading past EOF error

The following code compiles fine, but when I run the program it prints all the items in the file and then gives the following error: attempt to read past end of file `data.txt'


Var
DataFile : text;
data : Integer;
Filename : String;

Begin
Filename := "data.txt";
Assign(DataFile, Filename);
Reset(DataFile); {Reset(x) - means open the file x}


Repeat
read(Datafile, data);
write(" ");
write(data);
until Eof(Datafile)
end.

I also tried
While not Eof(Datafile) do
instead of repeat/until but it still does the same thing.

data.txt is attached
Sign In or Register to comment.

Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

Categories