title: Prolog - program skipping over read?
body: <p>Title more or less says it all. I got the following code in SWI-PROLOG:</p>
  <pre><code>get_card(1):-
      nb_getval(playerOneHand, Hand),
      write(&quot;Select which cards you want to play:&quot;), nl,
      read(Input),
      handle_input(Input).
  
  get_card(2):-
      nb_getval(playerTwoHand, Hand),
      write(&quot;Select which cards you want to play:&quot;), nl,
      read(Input),
      handle_input(Input).
  </code></pre>
  <p>Expected input-format right now is something like <code>[ 0, 1 ].</code> to play your first two cards, <code>[ 0 ].</code> to only play your first card, so on and so forth. While I know this is beyond horrible as far as input formats go, the priority right now is to atleast get it working, then move on to a better UI from there.</p>
  <p>This is what happens:</p>
  <p><a href="https://i.stack.imgur.com/ySrSN.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/ySrSN.png" alt="" /></a></p>
  <p>I'm very new to Prolog so bear with me, but this is how I'm looking at it: It seems to be &quot;skipping&quot; over our <code>read</code> and is now expecting a new command to be entered instead (ENTER has been pressed in the above picture).</p>
  <p>I feel like the solution should be very simple but unfortunately is nothing I can seem to wrap my head around. Thanks in advance!</p>
  <p><strong>EDIT:</strong> Example code that can be ran to reproduce the issue, unless it's only happening on my system for some reason:</p>
  <pre><code>% Initialize globals
  ?- nb_setval(playerOneHand, []).
  ?- nb_setval(playerTwoHand, []).
  
  handle_input(Input, Hand):-
      write(&quot;Input is &quot;), write(Input), nl,
      write(&quot;Hand is &quot;), write(Hand), nl.
  
  get_card(1):-
      nb_getval(playerOneHand, Hand),
      write(&quot;Select which cards you want to play: &quot;), nl,
      read(Input),
      handle_input(Input, Hand).
  
  get_card(2):-
      nb_getval(playerTwoHand, Hand),
      write(&quot;Select which cards you want to play: &quot;), nl,
      read(Input),
      handle_input(Input, Hand).
  
  ?- write(&quot;Player 1: &quot;), get_card(1), nl,
     write(&quot;Player 2: &quot;), get_card(2), nl.
  </code></pre>
  <p>Using SWI-Prolog and the given code in a <code>test.pl</code> file, it is simply consulted via the terminal interface (File -&gt; Consult -&gt; <code>test.pl</code>). Trying to give SWI-Prolog ANY kind of input then results in the issue at hand.</p>