The delimiter is actually \t (single tabulation). The following line
labels = np.loadtxt('synset_words.txt', dtype=str, delimiter='\n')
needs to be changed to
labels = np.loadtxt('synset_words.txt', dtype=str, delimiter='\t')
In CSV files new line means new row, that is a new entry. A delimiter is something the splits the columns in a single row.