changed from list.index(line) to dict[line] for index