Index to a temp file and then move it to the final location