Loops are done as sub-processes. Maybe someone else can give all the details, but if you change from your "cat file" then "do" logic to simply "do" and "done <file" you should be fine.
> cat set_val
#! /bin/bash
# array usage
# do no cat the file to the read, rather do a
# while .... done<file
i_ct=0
while read text
do
viko[$i_ct]=$text
i_ct=$(( i_ct + 1 ))
done <sample.txt
echo ${#viko[*]}
echo ${viko[*]}
echo $i_ct
echo ${viko[1]}