title: List of lists into modified single list
body: <p>These are predicates which reads from input file</p>
  
  <pre><code>read_line(L,C) :-
      get_char(C),
      (isEOFEOL(C), L = [], !;
          read_line(LL,_),% atom_codes(C,[Cd]),
          [C|LL] = L).
  
  %Tests if character is EOF or LF.
  isEOFEOL(C) :-
      C == end_of_file;
      (char_code(C,Code), Code==10).
  
  read_lines(Ls) :-
      read_line(L,C),
      ( C == end_of_file, Ls = [] ;
        read_lines(LLs), Ls = [L|LLs]
      ).
  </code></pre>
  
  <p>Input file:</p>
  
  <pre><code>A B
  C D
  E F
  G H
  </code></pre>
  
  <p><code>read_lines(L)</code> returns <code>L = [[A, ,B],[C, ,D],[E, ,F],[G, ,H]]</code>. My goal is to replace all the spaces and merge list of lists into single list. So expected output should look like: <code>L = [A-B,C-D,E-F,G-H]</code>.
  What I got so far is modified <code>read_line</code> function: </p>
  
  <pre><code>read_line(L,C) :-
      get_char(C),
      ( (char_code(C,Code), Code == 32)
          -&gt; C = '-'
          ; C = C),
      (isEOFEOL(C), L = [], !;
          read_line(LL,_),% atom_codes(C,[Cd]),
          [C|LL] = L).
  </code></pre>
  
  <p>When I use it, Prolog says <code>Syntax error: Unexpected end of file</code>. What's wrong with that?</p>