I agree with Dylan, context manager would be better here.