'Get the next string from the container, buffer it, and possibly send
the buffer to the writer.
The contents of the buffer are written when it is full or when no
further values are available from the container.
@raise StopIteration: When no further values are available from the
container.'

def next(self):

    try:
        v = self.iterator.next()
    except StopIteration:
        if self.lines:
            self.write(self.lines)
        del self.iterator, self.lines, self.write
        raise
    else:
        if (v is not None):
            self.lines.append(v)
            self.bufSize += len(v)
            if (self.bufSize > self.memoryBufferSize):
                self.write(self.lines)
                self.lines = []
                self.bufSize = 0
