File Reading and writing in Index