Update index.py

* call commit after each pdf file had been indexed
* if pdf can't be read, mark it as bad