I'm not sure if you really need FieldsIndex and i. This is the same as loop.count, right?
Maybe this can just be ```[% FOREACH [ 1 .. Config("NumberOfHederFields") ] %]```?