rewrote code that writes new index file