The program does that because that is what you wrote.

All your program does is

1) open a new output file (the wordDocument.open() function),
2) wait for a key to be pressed using the...