document.write can and should be avoided whenever you're writing new code. So while it'd probably still work, you should really look at a modern/async way to do the same.
document.write is still the only way to overwrite the current page completely, for use in userscripts: