function SaveStringToFile(const FileName: String; const S: AnsiString; const Append: Boolean): Boolean;
Saves the specified string to the specified file. If Append is True and the specified file already exists, it will be appended to instead of overwritten. Returns True if successful, False otherwise.
This function does not automatically write a line break before or after the string. If Append is True and the existing file did not end in a line break, the function will effectively append to the existing last line. To avoid this you can put line break characters before and/or after your string:
SaveStringToFile('c:\filename.txt', #13#10 + 'the string' + #13#10, True);