Revised to use HtmlTextWriter instead of just output, and to exit if the...

...re is no context item.