Use ClosingIterator to properly handle connection