while (read directory) { add to temp array; } examine array to set up loop vars for next loop while (loopvars tell us were still in the loop) { generate return array }