your code can get an instance of an already existing Document, and is used for script running "inside" the document (custom options, functions, etc.)
To create a new document instead, use:
// Create and open a document.
doc = DocumentApp.create('Document Name');
this works in any script.
To move the document on a specific folder, you have the method:
myFolder.addFile(doc);
For more info, look at DriveApp, DocumentApp, Document, File, Folder reference.