title: Java no token in next line but there should be?
body: <pre><code>public static void flipLines(Scanner input) {
      int i = 0;
      while (input.hasNextLine()) {
          String ignore = input.nextLine();
          if (i &gt;= 0) {
              System.out.println(input.nextLine());
              System.out.println(ignore);
          } i++;
      }
  }
  </code></pre>
  
  <p>I have this and I'm trying to flip lines from an input from scanner. I get a token error that says there is no line there when reading this text only on the very last line. Below is what it's supposed to look like when completely flipped but you can see in my version I lack the last line due to an error.</p>
  
  <pre>did gyre and gimble in the wabe.
  Twas brillig and the slithy toves
  and the mome raths outgrabe.
  All mimsey were the borogroves,
  "Beware the Jabberwock, my son,
  
  Beware the JubJub bird and shun
  the jaws that bite, the claws that catch,
  the frumious bandersnatch."</pre>
  
  <p>Here is the error and the output with flipped lines program. I have no idea why it would be out of token index when it should be printing the last line instead.</p>
  
  <pre>did gyre and gimble in the wabe.
  Twas brillig and the slithy toves
  and the mome raths outgrabe.
  All mimsey were the borogroves,
  "Beware the Jabberwock, my son,
  
  Beware the JubJub bird and shun
  the jaws that bite, the claws that catch,
  NoSuchElementException on line 9:
  No tokens remain in input.  Near input line 9
  
  java.util.NoSuchElementException: No tokens remain in input.  Near input line 9
      at Scanner._getNoSuchElementException(Scanner.java:1549)
      at Scanner.nextLine(Scanner.java:1254)
      at flipLines (Line 9)
  </pre>