Fixing the try with resources error