In test_write_index_file() change read() to readlines()