when I am reading this regex correctly it will match in case `$match` ends in `\n` and if so it will cut off the trainling `\n` and prepend another `\n`.
This does not sound like something which need to be handled using regex...?
Did I miss something?