When printing out information in an agent it is always useful to have your headers.
Stick this as the first print statement to produce the headerless page:
Print "Content-Type:text/html"