def isa_group_separator(line):
    return line == '\n'
with open('data_file') as f:
    for key, group in itertools.groupby(f, isa_group_separator):
        pass
Python: How to loop through blocks of lines