Fixed a bug in text formatting when an empty list is encountered.

Fixes #445