title: java.util.NoSuchElementException: No line found - Reading user input works only once
body: <p>I tried to create a very simple program (it doesn't matters, but a Minesweeper game), and I had the following problem: When I try to get the user input (with <code>Scanner</code>), it works the first time (on the first turn), but at the second turn, after pressing <kbd>enter</kbd>, it throws the following exception: <code>java.util.NoSuchElementException: No line found</code>.</p>
  
  <p>Nothing has changed between the two turns, and I create a new <code>Scanner</code> instance on every turn.</p>
  
  <p>The code:</p>
  
  <pre><code>public String nextTurn() {
      Scanner scn = new Scanner(System.in);
  
      System.out.print("Please insert your action: ");
      StringTokenizer input = new StringTokenizer(scn.nextLine());
      scn.close();
      //...
  }
  </code></pre>
  
  <p>Again, it works when I call this method the first time, but fails on the second call. Do you have an idea what the problem might be?</p>