inspect(In,Out) :-
catch( ( fast_read(In,Term), writeq(Out,Term), write(Out,'.\n') ),
error(E,_),
( E=syntax_error(_) ->
format(user_error,'Consistency error when reading from stream: ~w~n',[E]),
fail
; E=permission_error(_,_,_) ->
End=true % end of file
; E=consistency_error(_,_,_) ->
format(user_error,'Consistency error when reading from stream: ~w~n',[E]),
fail
;
format(user_error,'Unknown error when reading from stream: ~w~n',[E]),
fail
)
),
(End == true -> true ; inspect(In,Out)).