All you need to do is strip
each line. Change this line:
fo.write('%s,%s\n' %(eachline1,eachline2))
to this:
fo.write('%s,%s\n' %(eachline1.strip(),eachline2.strip()))
What's happening is that each line you read in has a newline (\n
) at the end. When you print them out, that newline is output. strip
removes the newline before outputting.