Using a do while loop is a tad redundant, particularly since you're just incrementing . You're better off using a for loop.