def iterBigFile(textfile, offset=0, size=None, maxSize=400, headSize=40,
    tailSize=None):
    """
    Yield lines from file textfile. If the size to read is bigger
    than maxSize then yield the first lines until headSize bytes, then
    yield None, then yield the last lines from tailSize bytes to the end.
    """
    if size is None:
        textfile.seek(0, 2)
        sizeKb = (textfile.tell() - offset) / 1024
    else:
        sizeKb = size
    headSizeB = headSize * 1024
    tailSizeB = (tailSize or headSize) * 1024
    textfile.seek(offset)
    if 0 < maxSize < sizeKb:
        for line in textfile.read(headSizeB).split('\n'):
            yield line + '\n'
        yield None
        textfile.seek(sizeKb * 1024 - tailSizeB)
    for line in textfile:
        yield line
