try:
    chunkfile.close()
except:
    print('Files already close')
if __name__ == '__main__':
    split_xml('wiki-files/tawiktionary-20110518-pages-articles.xml.bz2')
How to split large wikipedia dump .xml.bz2 files in Python?