Como verificar o EOF em Python?

Como faço para verificar EOF em Python? Eu encontrei um bug no meu código onde o último bloco de texto após o separador não é adicionado à lista de retorno. Ou talvez exista uma maneira melhor de expressar essa função?

Aqui está meu código:

def get_text_blocks(filename):
    text_blocks = []
    text_block = StringIO.StringIO()
    with open(filename, 'r') as f:
        for line in f:
            text_block.write(line)
            print line
            if line.startswith('-- -'):
                text_blocks.append(text_block.getvalue())
                text_block.close()
                text_block = StringIO.StringIO()
    return text_blocks

questionAnswers(5)

yourAnswerToTheQuestion