Use `try finally` to auto close stream