I can't seem to get proper multiline search and replace with either sed or perl -i. But I know how to do it in Python.