It seems as we were storing our list of modifications in a dict we couldn't rely
on the order of them coming out the dict, this was causing issues with \n and \r
and caused the output to have \\n or \\r. Switching to a list of tuples resolved
the issue.