Don’t close your scanner!!

NoSuchElementException if no more tokens are available Do not use scanner.close() <- source of your error! remove the lines scanner.close() and newScanner.close() From Java DOCs: When a Scanner is closed, it will close its input source if the source implements the Closeable interface. Which means it closes the System.in – bad choice! From source code…

Read More