import os file='bsw.txt' f=open(file,'r') ff=f.readlines() for line in ff: line=line.rstrip(" ") print line