Are you sure you're getting the NPE in the for loop? If anything, I would expect an NPE way back on Line 4 before you'd get one on Line 10. Is that a complete listing or did you omit some code in between Line 4 and Line 10?
The best ideas are the crazy ones. If you have a crazy idea and it works, it's really valuable.—Kent Beck