The program is crashing with message [i] out of range.
Then use a debugger and take a look at the backtrace why the assertion occours.