Search code examples
delphidelphi-2010

Write in textfile in Delphi


hi i am trying to make a delphi program that writes to a text file so far failed to achieve all but one detail is that the program writes well when used several times

hi
hi
hi

and I need to do so

hihihi

the code that I have so far is this

TForm1.Button1Click procedure (Sender: TObject);
var
   File: TextFile;

begin

   AssignFile (file, 'aca.txt');
   / / FileMode: = fmOpenWrite;

   if FileExists ('aca.txt') then
     Append (file)
   else
     Rewrite (file);

   Writeln (file, 'hi');
   CloseFile (file);

end;

Solution

  • Use Write instead of WriteLn.