In order to avoid a deep set of nested For loops, I came up with this method to do it with one For loop. The range of each level's For loop counting variable k1, k2, k3,... is 0 to b, and n is the number of nestings that I am replacing with one level. The advantage is for when n is a very large number. The disadvantage is lack of flexibility on the range of each counting variable.
Here is an example for n = 3 and b = 7:
b = 7; n = 3;
For[k = b^3, k < b^4, k++,
klist = RealDigits[k, b][[1]];
k1= klist[[2]];
k2 = klist[[3]];
k3 = klist[[4]];
(* the rest of the code is here... *) ]
Does anyone know of other ways to flatten nested For loops?