Working on writing the index to file