should not close standart input scanner

An execution of scanner.close closes System.in as well, thus next execution of scanner.nextInt throws NoSuchElementException.
To avoid this situation, just leave scanner open.