I want to save the contents of my richedit to a plain text file. With my current code, only a partial of the richedit's text ends up in the plain text. Could you please tell me what's wrong with my code:

var
    fSave : TextFile;
begin
     AssignFile(fSave, dlgSave.FileName + '.txt');
     Rewrite(fSave);
     Write(fSave, redAfvoer.Text);
end;

PS. A save dialog thing precedes this, this is just the snippet of code that has a direct influence on saving to the file.
This is what should be in the .txt file:

=== Hallo ===
== Hallo2 ==

========================================

 Koopprys in Rand: 	R 889 200.00

 Invoerkoste in Rand: 	R 88 920.00

 Hoeveelheid Produkte: 	200 Eenhede

========================================

 Invoerbelasting teen 3%: 	R 26 676.00

 Totale Koste: 	R 1 004 796.00

 Prys per Eenheid: 	R 5 023.98

But this is what ends up in it:

=== Hallo ===
== Hallo2 ==

========================================

 Koopprys in Rand: 	R 889 200.00

 Invoerkoste in Rand: 	R 88 920.00

 Hoeveelheid Produkte: 	200 Eenhede

========================================

 Invoerbelasting teen 3%: 	R 2

Where are you closing the file?

Thank you, good sir. I can't believe I actually missed that...urgh I'm a noob...

How on earth do you think, I thought about it. No, of course, not. I never forget to close my files :P

RichEdit1.Lines.SaveToFile('C:\txt.txt');
var
i: integer;
fSave : TextFile;
begin
AssignFile(fSave, 'C:\txt.txt');
Rewrite(fSave);
for i := 0 to RichEdit1.Lines.Count -1 do begin
Write(fSave, RichEdit1.Lines.Strings[i]);
end;
Append(fSave);
end;
Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.