title: Prolog: Adding elements to list through read/1
body: <p>I am trying to add user input to a list with add_read_list/2 until the word "end." is encountered. This is how the output is supposed to look:</p>
  
  <pre><code>add_read_list(Resultlist, [a,b]).
  |: c.
  |: d.
  |: e.
  |: f.
  |: end.
  Resultlist = [f,e,d,c,a,b].
  </code></pre>
  
  <p>This is how far I have come:</p>
  
  <pre><code> add_read_list(Resultlist,Entrylist) :- 
              read(end), append([], Entrylist, Resultlist).
  add_read_list(Resultlist, Entrylist) :-
              read(Input), append([Input], Entrylist, X),
              add_read_list(Resultlist, X). 
  </code></pre>
  
  <p>But this way every second input gets skipped:</p>
  
  <pre><code>add_read_list(Resultlist, [a,b]).
  |: c.
  |: d.
  |: e.
  |: f.
  |: end.
  Resultlist = [f,d,a,b].
  </code></pre>
  
  <p>What am I doing wrong?</p>