What you might consider doing is not advancing i unless the if's condition is met (in other words moving the i++ into the if statement).
The way it is now, the loop will go exactly 6 times regardless of whether or not you got a random number that you wanted. If you move i++ into the if, it will keep going until you have six random numbers that you can use.
Advance warning, be careful where in the if you put the i++. ;)