Can you show me what is outputted in the browser?
You should only see
Begin program end program
This is because document.write doesn't output to browser consoles.
Your code is absolutely fine. When you preview (using the eye icon in the corner) it loads in new browser tab.
If you right click on the webpage that loads and select Inspect, you will see the messages in the console of the browsers dev tools.
Hope this helps