I tried something like this and It doesn't work
counter = 0
with open('tmp.txt','a') as file:
while(counter == 0):
if file.readline() == "\n":
file.write("HI")
file.write("\n")
counter = 1
break
else:
continue
Following is the content of the text file.
1
2
3
4
5
6
7
8
9
0
How do I append text to the first occurrence of newline in the file and then add a new line