Implement document.write