Jamie,
Please update the pull request to include the attached code.
It is the same functionality as yours, but minus the Windows vs. Linux line ending (carriage return removed).
Also, the comments are in the correct place (on the condition line), so easier to read.

Read More...