Yeah I feel the right way to solve this bug (in the compiler) would be to stat the file. Or maybe docker mounts it with -noatime (or something similar?)
Yeah, this is obviously a replace vs in-place modify difference. Could replace the script with a simple copy-to-temp+rename-back.
Or not use ed(1).
Personally I use magnets to flip bits around, ed(1) seems a bit to bloated for me.