Are you using a plain <textarea> for input, or some WYSIWYG version like TinyMCE or FCKeditor? If the latter case, it may be inserting <br /> tags for line breaks, which you would then need to delete via a replace function using preg_replace() or str_replace().
PS: the preg check for "\r" might not be telling you anything, as you may only be getting "\n" for newlines.