Use try with resources instead of a try / finally pattern