How do I insert lines in the middle of a file

I'm trying to write a program that edits this .json in a noob-friendly way. I need it to put lines in between lines. What is the easiest way to do this?
You copy the file, line by line, and when you get to the place where you want you new line, you write it. Then you keep copying.
That, or simply load the file into memory, insert the line, and write the file back out.

Have you considered using a JSON library to help you out?
You copy the file, line by line, and when you get to the place where you want you new line, you write it. Then you keep copying.


How do I copy it line by line?
You open the file that you want to read from, and you open a file to write to.

You read a line from the input file, using a function such as getline. Then you write it out to the output file.
Topic archived. No new replies allowed.