I'm trying to write a procedure to find the number of lines in a text file -- as far as I can see, the following *should* work, but it gives wildly innacurate results and also messes up the rest of the program (which works fine when the procedure is disabled). What am I doing wrong??
procedure chooseline;
var counter:integer;
begin
assign (listofwords, 'F:\project\words.txt');
reset (listofwords);
counter:=0;
while not eof (listofwords) do
begin
repeat
read (listofwords);
until eoln (listofwords);
counter:=counter+1;
readln;
end;
end;
procedure chooseline;
var counter:integer;
begin
assign (listofwords, 'F:\project\words.txt');
reset (listofwords);
counter:=0;
while not eof (listofwords) do
begin
repeat
read (listofwords);
until eoln (listofwords);
counter:=counter+1;
readln;
end;
end;