Fix some bugs: getline, index of distance[][]