Mv: cannot access error after nested while loop

I have two methods...create_2_54 and create_2_55
I have added a nested while loop(previously it has just one loop) in create_2_54
the mv command(which comes first in 2_55) is not working.

for name in `ls -1 1SMH_WICD_V5_2_5*.txt` ; do
mv $name $nametmp.tmp
unix2dos -ascii -437 $nametmp.tmp $name
done

It says mv:cannot access 1SMH_WICD_V5_2_51.txt

It was working fine without nested loop in 2_54.

Correction:-

for name in 1SMH_WICD_V5_2_5*.txt
do
   mv $name ${name}tmp.tmp
   unix2dos -ascii -437 ${name}tmp.tmp $name
done
create_254()
{
> 1SMH_WICD_V5_2_54.txt
i=0
SORT=$(printf "%s\n" ${group_ARR[@]} | sort -n | uniq)
set -A SORTED_ARR `echo ${SORT}`
while [ $i -lt ${#SORTED_ARR[@]} ]
do

print $RESOURCE_TYPE$deli${SORTED_ARR}$deli$SOR$deli$ID_LOCATION$deli$PRIV_INDICATOR$deli${SORTED_ARR}$deli$ATTR_VAL1$deli$nospace$deli$nospace$deli$nospace$deli$ID_LOCATION$deli$STATUS$deli$OWNAPP$deli$SOURCE_ID >> 1SMH_WICD_V5_2_54.txt

((i=i+1))
 
done
}
 
create_255()
{
for name in `ls -1 1SMH_WICD_V5_2_5*.txt` ; do
mv $name $nametmp.tmp
unix2dos -ascii -437 $nametmp.tmp $name
done
}

---------- Post updated at 11:37 AM ---------- Previous update was at 11:34 AM ----------

create_254()
{
> 1SMH_WICD_V5_2_54.txt
i=0
SORT=$(printf "%s\n" ${group_ARR[@]} | sort -n | uniq)
set -A SORTED_ARR `echo ${SORT}`
while [ $i -lt ${#SORTED_ARR[@]} ]
do


 
IFS=', '; set -A arr $(echo "$ATTR_VAL1")
j=0
while [ $j -lt ${#arr[@]} ]
do
print $RESOURCE_TYPE$deli${SORTED_ARR}$deli$SOR$deli$ID_LOCATION$deli$PRIV_INDICATOR$deli${SORTED_ARR}$deli${arr[j]}$deli$nospace$deli$nospace$deli$nospace$deli$ID_LOCATION$deli$STATUS$deli$OWNAPP$deli$SOURCE_ID >> 1SMH_WICD_V5_2_54.txt

((j=j+1))
done
((i=i+1))
done
}
create_255()
{
for name in `ls -1 1SMH_WICD_V5_2_5*.txt` ; do
mv $name $nametmp.tmp
unix2dos -ascii -437 $nametmp.tmp $name
done
}

---------- Post updated at 11:39 AM ---------- Previous update was at 11:37 AM ----------

I dont know how this nested loop related to mv command.

Please help me guys...Its urgent

---------- Post updated at 01:09 PM ---------- Previous update was at 11:39 AM ----------

Thanx dude