Using try-with-resource to ensure stream will be properly closed after usage