Refactoring more try statements to be try-with-resources