Writing and reading the correct index.