Vamos a ver si lo puedo hacer de memoria:
Código Delphi
[-]
procedure Log(Str: String; Archivo: String);
begin
with TStringList.Create do
try
try
LoadFromFile(Archivo);
except
end;
if Count > 0 then
if Strings[Count-1] = Str then
Exit; while Count > 4 do
Delete(0);
Add(Str);
SaveToFile(Archivo);
finally
Free;
end;
end;