for each string in your list, use .strip()
which removes whitespace from the beginning or end of the string:
for i in contents:
alist.append(i.strip())
But depending on your use case, you might be better off using something like numpy.loadtxt
or even numpy.genfromtxt
if you need a nice array of the data you're reading from the file.