Removed document.write call and replaced with an appendChild call.