I have a simple text file with several thousands of words, each in its own line, e.g.
aardvark hello piper
I use the following code to load
To remove only the right hand spaces.
set(map(str.rstrip, open('filename.txt')))