need help with korn shell array

I have a korn shell script that reads a file with just one column in the file. If the file has more than 5 entries it is split using split -5. This means that is we have 15 entries I will end up with 3 files with 5 entries/lines in each and if I have 23 entries I will end up with 5 files with the last file containing only 3 entries/lines. I have a for loop that reads the entries in each of the files into an array. The problem is that when the last files has less than 5 entries and I do a print ${array
[*] it ends up printing 5 entries.

Fo example if my ladst file has only 3 entries I end up printing the 3 entries and the last 2 entries from the previous file.

Can somebody tell me what is wrong with this syntax. Thanks!

/usr/bin/split -5 /tmp/export_sort.$$ /tmp/export_sort.$$_

for FILE in `ls /tmp/export_sort.$$_*`
do
i=0
for V in `cat $FILE`
do
array[i]="$V"
((i=i+1))
done

echo "Line entries from $FILE = ${array
[*]}"

done

Try to reset your array before reading each file

/usr/bin/split -5 /tmp/export_sort.$$ /tmp/export_sort.$$_

for FILE in `ls /tmp/export_sort.$$_*`
do
   i=0
   unset array
   for V in `cat $FILE`
   do
      array="$V"
      ((i=i+1))
   done
   echo "Line entries from $FILE = ${array[*]}" 
done 

Jean-Pierre.

Thank you so much. "unset array" works now!