I run the following code and expect to get all the words from the link below in a list without repeating any word. How determine if a word is unique?

Solution for I run the following code and expect to get all the words from the link below in a list without repeating any word. How determine if a word is unique?
is Given Below:

fname = input(“Enter file name: “)

if len(fname) < 1 : fname = “romeo.txt”

fh = open(fname)

lst = []

loop over the text

for lin in fh:
# split the lines
lin = lin.rstrip()
lin = lin.split()
# loop over the split lines
for a in lin:
# write a condit to determine if a word is unique
# append the word to the empty list
lst.append(a)

lst.sort()
print(lst)

https://www.py4e.com/code3/romeo.txt?PHPSESSID=4eb3426c73615745fa14760acf0d7a88

text = """
But soft what light through yonder window breaks
It is the east and Juliet is the sun
Arise fair sun and kill the envious moon
Who is already sick and pale with grief
"""
words = list(dict.fromkeys(list(filter(None, text.replace("n", " ").split(" ")))))

The Code Splits the words, removes empty strings, then removes duplicates:

W3schools remove duplicates

Remove empty strings from a list of strings