Replacing a word with a buch of lines

Input file:

I want to replace "change" with the below lines

What is the best way to replace it?

sed...

sed 's/change/print();\nclose();/' infile

awk...

awk '/change/{print "print();\nclose();";next}1' infile

thanks.

I have the replacement lines in stored in a file. how does it work in that case?

how does the file looks like, can you show example of the file?

replace.txt

awk '/change/{system("cat replace.txt");next}1' infile