dannable:
Could you go through the steps of what your program is doing? The logic of it? I personally don't understand the for loop.
+1
Describing the detailed steps of the program in plain language (rather than computer code) is a great way to discover errors and uncertainties in the logic.
...R