Java Scanner strange behavior
<p>I have a java scanner and two loops to handle user input, However it throws an <code>NoSuchElement</code> exception the second it hits the first loop with out asking for any input from the user. </p>

<pre><code>Scanner Guess_input = new Scanner( System.in );


    while (guess &gt; 0){
        failure = true;
        while(failure)
        {

            System.out.println("Please input");
            try
            {
                if (Guess_input.nextLine().length() == 1 &amp;&amp; guesses.size() &gt;= 1) {
                    guesses.add(Guess_input.nextLine());
                    System.out.println("You guessed" + guesses.get(guesses.size()) + "");
                }
                else if (Guess_input.nextLine().length() == 0) {
                    System.err.println("ERROR:");
                    Guess_input.nextLine();   //Clean Buffer
                    failure = true;
                }
                else 
                {
                    System.err.println("ERROR");
                    Guess_input.nextLine();   //Clean Buffer
                    failure = true;
                }
            }   
            catch(InputMismatchException ime)

            {
                System.err.println("error");
            }
            finally
            {
                Guess_input.close();
            }
        }
    }
</code></pre>
