Just a not to StringReplace.
Had a situation with importing files, where someone went overboard with the enter button, to create new lines, so there could be more than for #13's in a row...
[rfReplaceAll] is not recurive,
so StringReplace(aString, #13#13, #13, [rfReplaceAll])
will only replace from the original - not with the charaters replaced.
A string with #13#13#13# or 13#13#13#13 would contain #13#13 after replacement
So constructions like
while Pos(#13#13, aString) do aString := StringReplace(aString, #13#13, #13, [rfReplaceAll])
may be needed