I am creating a command line tool in node. After the user enters a specific command I parse through the options they have entered. 

```
> mycommand init --name name --email user@domain.com

```

I then validate the values of the options. After validation I generate an array of questions that were not answered from the options the user entered and from the entered options that did not pass validation. Once the array has been generated, I loop through it and give a prompt for each question:

```
    for(var i = 0; i < questions.length; i++) {
        var prop  = questions[i],
            title = messages.prompts.init[prop].question,
            def   = messages.prompts.init[prop].def,
            input = read.createInterface(process.stdin, process.stdout);

        if(messages.prompts.init[prop].hasOwnProperty('format')){
            title = title + ' <' + messages.prompts.init[prop].format + '> '; 
        }

        input.question(title + ' (' + def + ')', function (a) {
            //dosomething(a);
            process.exit();
        });
    }

```

The problem is, the code loops through the entire array without waiting for the user input and ends with a final prompt displaying a message from the last item in the array. When I try to type a response, each keystroke is multiplied by the number of items in the array. For instance, attempting to type "myname" results in:

```
> Enter Your Name (none): mmmmyyyynnnnaaaammmmeeee

```

I have tried multiple node modules including [read](https://www.npmjs.org/package/read) and [prompt](https://www.npmjs.org/package/prompt) and am experienceing the same problem So I must not fully understand how command line tools read user input. 

Any insight on how to solve this problem would be appreciated. 

Thanks.