title: How to check if Prolog going to return false?
body: <p>Here is a portion of my code: </p>
  
  <pre><code>find_paths(A, B) :-
      path([A], B, Path, 0, Length),
      reverse(Path, DirectPath),
      printPath(DirectPath),
      writef(' with distance of %d\n', [Length]),
      ("IF PROLOG RETURN FALSE", write('End'); fail).
  </code></pre>
  
  <p>All the other parts are working fine except for when I wanted it to check if it returns false after retrieving all the data from database from looping.
  "IF PROLOG RETURN FALSE" is where I wanted to insert the checking part but I don't know what to put. 
  I tried the code below but it doesn't output the 'End' word.</p>
  
  <pre><code>find_paths(A, B) :-
      path([A], B, Path, 0, Length),
      reverse(Path, DirectPath),
      printPath(DirectPath),
      writef(' with distance of %d\n', [Length]),
      fail,
      write('End').
  </code></pre>