And that is the way it's supposed to work..
If you use document.write() to output to the page while it is still loading, then the output will be on the current page. If you use document.write() after the page has finished loading, as in this case, the output goes to a new document.
What you need to do in this case is use getElementById() to get an object reference to the element you want to display the message in and then assign the message to the innerHTML property of the element's object reference. And then the error message will appear on your current opened web page.
Also, checking each radio button individually is a very inefficient way of doing it and results in bloated code. A much more efficient way is to use a single loop to loop through your array of radio buttons to ensure one of them is checked.