#!/usr/bin/env python3
f='bibliography.bib'

indexes=[]
flag = False

with open(f) as fh:
    for line in fh.readlines():
        if flag is True:
            print(line.rstrip())
            if line[0] == '}':
                flag = False
        if line[0] == '@':
            index = line[line.find('{')+1:line.find(',')]
            if index.strip() in indexes:
                continue
            else:
                indexes.append(index.strip())
                flag = True
                print(line.rstrip())