                                (* Chapter 11 - Program 3 *)
program Read_And_Store_A_File;

var Read_File        : text;
    Input_File_Name  : string[12];
    Write_File       : text;
    Output_File_Name : string[12];
    Line_Number      : integer;
    Big_String       : string[80];
    Read_File_OK     : boolean;

begin
   Write('Enter input file name ');
   Readln(Input_File_Name);
   Assign(Read_File,Input_File_Name);
   {$I-}
   Reset(Read_File);
   {$I+}
   Read_File_OK := (IOResult = 0);
   if Read_File_OK then begin
      Write('Enter output file name ');
      Readln(Output_File_Name);
      Assign(Write_File,Output_File_Name);
      Rewrite(Write_File);

      Line_Number := 1;
      while not Eof(Read_File) do begin
         Readln(Read_File,Big_String);
         Write(Write_File,Line_Number:5,'  ');
         Writeln(Write_File,Big_String);
         Line_Number := Line_Number + 1;
      end;
      Close(Read_File);
      Close(Write_File);
   end
   else
      Writeln('Input file doesn''t exist, execution aborted');
end.  (* of program *)




{ Result of execution

(The selected file is copied to the selected output file)

}
