"Use the FIND, CHANGE, and LINE_AFTER macro instructions. " ...and they dont work [ and I must say they would have been the first things I would try ] ... why/how not?.......or do you just want the macro coding?

I am happy to see you were able to implement my suggestion and solve your problem.

BUT
I noticed that you do not check the return-code from the service call.

to write professional code/scripts, one should always insure that a call to a service,
whether it be an ISPF/SQL/File I-O/Language Environment,
be followed by a check of the return-code of that service.
Without doing so, you have no idea if the requested function/service performed as expected/wanted.

The difference between writing good code and BSing with the boys,
is being exact.

most good professionals that I know,
have private libraries of JCL/code/Scripts that they carry with them
(zipped and transferred via email)
from site to site,
which contain professionally written examples that can be easily and quickly copied and pasted.

with the innovation of CUT&PASTE (mainframe clipboard) professionally coding in ISPF has become very easy.