Whitespace is important to some reports, like diff, so don't trim
Whitespace at the end of lines is important to diffs, so use shell_exec() instead. Also removed unused method.
Added fixes for newline errors at end of file