Use try-with-resources for closing the stream