Improves readline's word detection.

Also fixes a crash when no "word" was matched.