procedure TForm1.Button1Click(Sender: TObject); var F:TextFile; fName: string; begin fName := 'error.txt'; AssignFile(F,fName); if FileExists(fName) then Append(F) else Rewrite(F); Writeln(F, 'this is string'); CloseFile(F); end;