I am working on a tokenizer in prolog, and i keep getting the following error when attempting to open a file and pass the stream into a predicate: ERROR: at_end_of_stream/1: stream `(0x7fe83d800090)' does not exist. I am attempting to open a file "ass3IN" with the following query:?- tokenizer('ass3IN',A). I have been trying to solve this for a while and any help would be greatly appreciated. Thanks in advance.
1 tokenizer(File,_) :-
2 open(File,read,Str),
3 getchars(Str,Tokenlist),
4 close(Str),
5 unifywhitespace(Tokenlist,Newlist),
6 rem_consec_white(_,Newlist,No2white).
7
8 getchars(Stream,_) :-
9 at_end_of_stream(Stream).
10
11 getchars(Stream,List) :-
12 \+ at_end_of_stream(Stream),
13 get0(Stream,C),
14 append(List,[C],List1),
15 getchars(Stream,List1).