У меня Free Pascal и всё работает.
Немрого подправил( на случай если слов меньше 20):
const n=20;
type Z= array[1..n] of string;
var f,f1: Text;
s,s1: string;
c: char;
j,i,t: byte;
A: Z;
begin
Readln(s);
Assign(f,'Text_in.txt'); Rewrite(f);
Writeln(f,s);
Reset(f);
s1:=''; t:=1;
While not Eof(f) do
Readln(f,s);
for i:=1 to Length(s) do begin
c:= s[i];
if (c<>',') and (c<>'.') then
s1:= s1+c
else begin
A[t]:= s1;
Inc(t);
s1:='';
if (t>n) then Break;
end;
end;
for i:=1 to n-1 do
for j:=1 to n-i do
if A[j]>A[j+1] then begin
s:= A[j];
A[j]:= A[j+1];
A[j+1]:= s
end;
Assign(f1,'Text_out.txt');
Rewrite(f1);
i:=1;t:=1; s1:='';
repeat
if A[i]=s1 then Inc(i)
else
if A[i]=A[i+1] then begin
Inc(t);
Inc(i)
end else begin
Writeln(f1,A[i],'-',t);
t:=1;
Inc(i)
end;
until i>n;
Close(f);
Close(f1);
end.