How to add a third line in file.txt:
             line 1
             line 2
             line 4
sed could do with sed '3iline 3' file.txt but I want to output to the same file.
I tried sed '3iline 3' file.txt >> file.txt which didn't work. It did add the line but it duplicates file.txt, I got this:
       line 1
       line 2
       line 4
       line 1
       line 2
       line 3
       line 4
 
    