procedure TForm1.Button1Click(Sender: TObject);
var
InFile: TextFile;
OutFile: TextFile;
Str: string;
begin
AssignFile(InFile, 'ResidentData.TXT');
{$I-} ReSet(InFile); {$I+}
if IOResult <> 0 then
begin
Label1.Caption := 'bad input file';
exit;
end;
AssignFile(OutFile, 'NewDirectory.TXT');
{$I-} ReWrite(OutFile); {$I+}
if IOResult <> 0 then
begin
Label2.Caption := 'bad output file';
CloseFile(InFile); // don't forget to close the infile
exit;
end;
while not EOF(InFile) do
begin
ReadLn(InFile, Str);
WriteLn(OutFile, Str);
Label3.Caption := 'no need for line count';
end;
CloseFile(OutFile);
CloseFile(InFile); // don't forget to close the infile
end;