You should be (1) deleting everything up to and including "1.#####", then (2) applying the appropriate transformation to what remains. Looking at my code for this step, I see that I removed one newline character at the end of the file before doing everything else, and this apparently yielded the correct result; I didn't do this in subsequent steps.
(I've been playtesting this thing for a while. I'm not all the way through yet.)
(I've been playtesting this thing for a while. I'm not all the way through yet.)