Multiple matches cause unnecessary newlines in replace_or_add

If the pattern is matched by more than one line in the file, the second comparison (and all the following ones) would always fail since `new_resource.line` already ends with `\n` at that point.  Therefore, these matches line would be replaced with the same line _plues another newline_.

This change should avoid that :)