Do some debugginng to see where it fails;
uses sysutils;
var
filein, fileout: textfile;
mychar: char;
begin
{$I-}
if not fileexists('mute.txt') then begin writeln('mute.txt is not there'); halt; end;
assign (filein, 'mute.txt');
reset (filein);
if IOResult <> 0 then begin writeln('IO Error on Reset mute.txt'); halt; end;
if not fileexists('mute2.txt') then begin writeln('mute2.txt is not there'); halt; end;
assign (fileout, 'mute2.txt');
rewrite (fileout);
if IOResult <> 0 then begin writeln('IO Error on Rewrite mute2.txt'); halt; end;
read (filein, mychar);
if IOResult <> 0 then begin writeln('IO Error on Read from mute.txt'); halt; end;
write (fileout, mychar);
if IOResult <> 0 then begin writeln('IO Error on Write to mute2.txt'); halt; end;
close(filein);
if IOResult <> 0 then begin writeln('IO Error on Close mute2.txt'); halt; end;
close(fileout);
if IOResult <> 0 then begin writeln('IO Error on Close mute2.txt'); halt; end;
end.
Bit over the top, but it should halt at the first IO Error.
Strange behaviour though when both mute.txt and mute2.txt are zero byte files.
It runs without error, but shouldn't it set InOutRes to some non-zero value, because the read(filein,mychar) should fail???
(I know it can be prevented by first checking Eof(filein) )
It then writes a ^Z (on linux!) to mute2.txt.
Tested on linux with fpc 2.2.4.
Bart