[IMPR] some improvements for data_ingestion.py
[IMPR] some improvements for data_ingestion.py

- use try..else instead of continue inside exception
- use contextlib.closing to close a file

Change-Id: Ic2c0b043d23065b95d34d9034eb27e3a3822f069

wikimedia/pywikibot-core,PersianWikipedia/pywikibot-core,wikimedia/pywikibot-core