file="f:/20180904.txt" with open(file,"r") as f: content=f.readlines() # for x in range(len(content)): # if content[x]!="\n": # print(x, content[x]) file2="f:/2018090401.txt" with open(file2,"w") as f2: for x in range(len(content)): if content[x]!="/n": f2.write(content[x])