Hi,

To post code in the forum, simply wrap the code with
tags, e.g.,

[code]Your
code
here.

The problem is in your 'for' loop: