I'm not sure if you're still having problems with the control codes, but from what I've seen you should only have to update the following codes when you insert text:
First line of file = 4-byte data offset, 4-byte resource section offset, 8 bytes 0xFF.
D000XXXX = goto relative X (data offset --...