Using while instead of for loop.