implemented the 'foreach' construct for each while-loop construct