Fails to add newline after patch, fails to remove last character that needs to be removed

Author: stefanmatarCreated Jul 17, 2023Updated Oct 25, 2023

Given:

@@ -1,5 +1,5 @@
 A
 B
-C
+XYZ
 D
-E

On file:

A
B
C
D
E

It returns 'A\nB\nXYZD\nE' but should be 'A\nB\nXYZ\nD'