I suppose that's not what you meant, but I cannot stop thinking of the poor sysadmin whose files keep getting unexpectedly trimmed to exactly 397 lines.
Also, btw, you can absolutely use ed in scripts [0], but this is also something that I would pity the maintainer of.