Insert into textfile

I have a text file that I want to insert a new line into between the
first and second line. Is there a way to do this?

content =‘test.txt’)

sub does replace the first occurence of a new line in the file


Actually, that was close.
This is what I was kind of looking for.

content =‘exam.txt’)
content.sub!("\n","\nNew Content\n")‘exam.txt’,‘r+’).write(content)

But this doesn’t work if the first line doesn’t end in a new line