use try-with-resources for auto closing opened input stream