Error in a pilotscript

Hi friends

In the process of understanding pilot script, i thought i will try with elementary examples. one of them was to calculate the average from a variable count, but am not getting my desired result. the protocol is as under with the pilot script:

INPUT DATA: data\Tables\phenobarbital.txt

PROTOCOL: Delimited text reader--create new property--custom manipulator--html viewer

                                                                 (average was created)

PILOT SCRIPT USED :

#total := 0;

FOR #index in 1 ..NumValues(Blend)

LOOP

#total += Blend[#index];

END LOOP;

#average := #total/NumValues(Blend);

what could be wrong in my protocol?