Detect endquote only before spaces, punctuation and newlines.

Should fix issue #49.