Because the RESConsole is not yet append to the document. But I would move the code after if you prefer.