Fix small error introduced by earlier retain newline fix.

The last retain newline fix did not check for if p < n before trying to retain the newline.
If this check is not made it will cause the position to go past the null byte on strings
that do not end with a newline character.
Merge pull request #197 from RickEyre/retain-newline-fix

Fix small error introduced by earlier retain newline fix.