er ... how do I open a exsit file and write extra string into any line(s) in the original file

like say the original file is

ABCDHIJKLMN...

and i wanna insert EFG into ABCD and HIJ...

what should i do? :s