function TEmmet.GetLineCount(const s: string): Integer;
var
n: Integer;
begin
Result := 1;
n := Pos(#10,s);
while n > 0 do
begin
Inc(Result);
n := PosEx(#10,s,n+1);
end;
end;
Simpler code can be
using of S.CountChar(#10) + 1.
function CountOfChar(ch: Char; const S: string): Integer;
var
i: Integer;
begin
Result := 0;
for i := 1 to Length(S) do
if S[i] = ch then
Inc(Result);
end;
Simpler code can be using of
S.CountChar(#10) + 1
.https://www.freepascal.org/docs-html/rtl/sysutils/tstringhelper.countchar.html (fpc) / https://docwiki.embarcadero.com/Libraries/Sydney/en/System.SysUtils.TStringHelper.CountChar (delphi).
or using this simple func.