program fjf219c;

uses GPC;

var
  s : String (100);
  f : ^Text;

procedure DontFreeMem (aPointer : Pointer);
begin
end;

begin
  FreeMemPtr := @DontFreeMem;
  New (f);
  Rewrite (f^);
  WriteLn (f^,'failed');
  Dispose (f); { f should be automatically cleaned here }
  {$I-}
  Reset (f^); { so re-opening f will open another internal file (or fail completely) }
  {$I+}
  if IOResult = 0 then
    begin
      ReadLn (f^,s);
      WriteLn ('failed ', s)
    end
  else
    WriteLn ('OK')
end.
