Using try-with-resources if we use Scanner to close the underlying stream is a good practice to handle resources. Minimal refactor.
Using try-with-resources if we use Scanner to close the underlying stream is a good practice to handle resources. Minimal refactor.