Fix for issue where empty tags are left appended to output.

Change ensures that immediate break from parsing occurs when
the character or word limit is hit.
Includes test.