working while loop to get directory names and put in kstack