Made a better method for updating document index (using bash)