read a file line by line into a list,lines = [line.rstrip('\n') for line in open('filename')]