title: Can't access to a file in Prolog, always read the end_of_file atom
body: <p>I am studying Prolog using SWI Prolog and I am finding some difficulties related to the operation of reading and writing on a file.</p>
  
  <p>I have this simple program that read something from the standard input (the keyboard) and write it on a file:</p>
  
  <pre><code>processFile(File) :- see(File),
                   processFile,
                   seen.
  
  processFile :- read(Query),
                 process(Query).
  
  process(end_of_file) :- !.
  
  process(Query) :- Query,
                    write(Query),
                nl,
                processFile.
  </code></pre>
  
  <p>I am trying to execute it under Linux. So in the bash I go into the folder where it is located the Prolog source file and the <strong>myFile</strong> file and, after that I have consult the program, I execute the following statment:</p>
  
  <pre><code>?- processFile(myFile).
  true.
  </code></pre>
  
  <p>as you can see the probem is that give me true but I can't insert anything by the keyboard, so anything could be write into <strong>myFile</strong> file.</p>
  
  <p>If I try to trace what happen I obtain the following informations:</p>
  
  <pre><code>[trace]  ?- processFile(myFile).
     Call: (6) processFile(myFile) ? creep
     Call: (7) see(myFile) ? creep
     Exit: (7) see(myFile) ? creep
     Call: (7) processFile ? creep
     Call: (8) read(_G697) ? creep
     Exit: (8) read(end_of_file) ? creep
     Call: (8) process(end_of_file) ? creep
     Exit: (8) process(end_of_file) ? creep
     Exit: (7) processFile ? creep
     Call: (7) seen ? creep
     Exit: (7) seen ? creep
     Exit: (6) processFile(myFile) ? creep
  true.
  </code></pre>
  
  <p>As you can see it can access to <strong>myFile</strong> file, and correctly ask the <strong>processFile</strong> predicate that contain the <strong>read</strong> statment but seems that automatically read the <strong>end_of_file</strong> atom and can't go on.</p>
  
  <p>Why? what can I do to solve it and write into this file?</p>