Be more careful when adding <!doctype> to our output.

Change-Id: I1f93e6244496456c0c56f982ad84ad6782f42e0b