1with open("new_file","r") as f:
2 for i in f.readlines():
3 if not i.strip():
4 continue
5 if i:
6 print i,
7
1with open(fname, 'r+') as fd:
2 lines = fd.readlines()
3 fd.seek(0)
4 fd.writelines(line for line in lines if line.strip())
5 fd.truncate()
6