The most common way do text-processing in Delphi is to load a file into a TStringList and then process the text line-by-line.  Often you need to save the contents of the StringList back to the file.  The TStringList is one of the most widely used RTL classes.  However there are a number of limitations discussed below:   a) No easy way to preserve line breaks on Load/Save TStringList does not make any effort to recognize the type of line breaks (LF, CR or CRLF) in the files it opens, let alone save that for use on saving.   b) Information loss without any warning or any option for dealing with that. Internally TStringList uses unicode strings, but when you save its contents to a file using the default encoding (ANSI), this may result in information loss, without getting any warning or having any means for dealing with that.  TEncoding.GetBytes also suffers from that.   c) No easy way to determine whether a file you loaded into a TStringList contained a BOM When you load a file (LoadFromFile method), the encoding of the file is stored but not the information about whether the file contained a BOM or not.  The WriteBOM property is only used when you save a file.   d) Last but not least, no easy way of dealing with utf8 encoded files without a BOM The default text file format in Linux systems, in Visual Studio Code and other editors, as well as in languages such as python 3 is utf8 without BOM.  Reading such files with TStringList is problematic and can result in errors, because it thinks such files are ANSI encoded.  You could change the DefaultEncoding to utf8, but then you get errors when you read ansi files.  No effort is made to detect whether a file without a BOM contains utf8 sequences.   Overall, it is desirable that, when you load a file using LoadFromFile and then you save it using SavetoFile, the saved copy is identical to the original.   I am attaching a general purpose TStringList descendent that deals with all the above issues in case anyone has a use for that. XStringList.pas