Rewrite the index file