I have opened the file I want to write to using:
data = open(\'input\',\'a\')
using a loop, I want to write some words to the file in the s
Try removing data.write("\n") .
data.write("\n")
while loop: for loop: /*do something */ if some_condition: data.write(str(tag)+"") data.write(" ")
In other words, remove the data.write("\n");
Remove the newline at the end of tag before writing it.
tag
data.write(str(tag).rstrip('\n'))