Fixed try-with-resources bug.