writing index to disk