не понимаю как исправить ошибку: "Ошибка времени выполнения: Попытка считывания за концом текстового файла"

дана следующая задача: А. Создать файл, содержащий сведения о личной коллекции книголюба. Структура записи - шифр книги, автор, название, год издания, местоположение (номер стеллажа, шкафа и т.д.). Количество записей - произвольное. Б. Найти:

  1. местонахождение книги автора Х названия Y;

  2. список книг автора Z, находящихся в коллекции;

  3. число книг издания ХХ года, имеющееся в библиотеке. Значения Х, Y, Z, XX ввести с клавиатуры

    program p3;

     type
       Book = record
         code: integer;
         author: string;
         title: string;
         year: integer;
         loc: string;
       end;
    
     var
       collection: array [1..100] of Book;
       authorX, titleY, authorZ: string;
       total, yearXX, i, cnt: integer;
       flag: boolean;
       f: text;
    
     begin
       assign(f, 'bookCollection.txt');
       reset(f);
    
       total := 1;
    
       while not eof(f) do
     begin
       if total < 100 then 
       begin
         readln(f, collection[total].code, collection[total].author, collection[total].title, collection[total].year, collection[total].loc); // *****{----тут ошибка----}
         if (collection[total].code <> 0) and (collection[total].author <> '') and (collection[total].title <> '') and (collection[total].year <> 0) and (collection[total].loc <> '') then
         begin
           total := total + 1;
         end;
       end
       else
       begin
         writeln('Array is full. Increase the size of the "collection" array.');
         break;
       end;
     end;
    
       close(f);
    
       writeln('input author X: ');
       readln(authorX);
       writeln('input title Y: ');
       readln(titleY);
       writeln('input author Z: ');
       readln(authorZ);
       writeln('input year ХХ: ');
       readln(yearXX);
    
       flag := false;
       cnt := 0;
    
       for i := 1 to total do
       begin
         if (collection[i].author = authorX) and (collection[i].title = titleY) then
         begin
           writeln('book location: ', collection[i].loc);
           flag := true;
         end;
    
         if collection[i].author = authorZ then
           writeln('authors book ', authorZ, ': ', collection[i].title);
    
         if collection[i].year = yearXX then
           cnt := cnt + 1;
       end;
    
       writeln('count books of ', yearXX, ' year: ', cnt);
    
     end.
    

Ответы (0 шт):