title: Exception in thread "main" java.util.NoSuchElementException at java.util.Scanner.throwFor(Unknown Source) at java.util.Scanner.next(Unknown Source)
body: <p>I am getting <code>java.util.NoSuchElementException</code>.</p>
  
  <p>Scanner only works one time (the first loop). </p>
  
  <p>The full stack trace is: </p>
  
  <blockquote>
    <p>Exception in thread "main" </p>
  
  <pre><code>java.util.NoSuchElementException at
  
  java.util.Scanner.throwFor(Unknown Source) at
  
  java.util.Scanner.next(Unknown Source)
  </code></pre>
  </blockquote>
  
  <p>Could you please help me fix my code:</p>
  
  <pre><code>import java.util.Scanner;
  import java.io.*;
  
  public class Main {
  
      public static void main(String[] args) throws IOException {
          Scanner input = new Scanner(System.in);
          String answer;
          do
          {
              input = new Scanner(System.in);
  
              System.out.println("MAIN MENU");
              System.out.println("- Start a new Game (S)");
              System.out.println("- Exit (E)");
              System.out.println("Please enter your choice: ");
  
              answer = input.next();
  
              if (answer.equals("s") || answer.equals("S"))
              {
                  Hangman h1 = new Hangman();
                  h1.getWord();
                  h1.printData();
                  h1.CountTheLetters();
                  h1.GiveTheLetters();
              }
          } while (!answer.equals("e") &amp;&amp; !answer.equals("E"));
          input.close();
          System.out.println("Thank you for the game");
      }
  }
  </code></pre>