title: Reading a file in prolog
body: <blockquote>
    <p><strong>Possible Duplicate:</strong><br>
    <a href="https://stackoverflow.com/questions/4805601/read-a-file-line-by-line-in-prolog">Read a file line by line in Prolog</a>  </p>
  </blockquote>
  
  
  
  <p>I found the following prolog code which reads one character at a time and prints out.</p>
  
  <pre><code>process(File) :-
          open('C:/Users/BHARAT/Desktop/a.txt', read, In),
          get_char(In, Char1),
          process_stream(Char1, In),
          close(In).
  
  process_stream(end_of_file, _) :- !.
  process_stream(Char, In) :-
          print(Char),
          get_char(In, Char2),
          process_stream(Char2, In).
  </code></pre>
  
  <p>But if the file has multiple lines is there a way to read 1 whole line at a time so that it will be easy for tokenizing.</p>