Replace string in ksh

Hello, I want to locate a special character in each line of a file and replace it with another string that contains a special character and $i (i is incresing each cycle)
string1: export IBAN[]=AAAAAAAAA . . . . export IBAN[]=zzzzzzzzzzz
I want it to be:
export IBAN[1]=AAAAAAAAA . export IBAN[940]=fjkjfkojfojfojo . . export IBAN[1000]=zzzzzzzzzzz
I have a script that find character='[]' and need to replace it with '[$i]'

#!/bin/ksh  
i=0  
while read line do 	
#new=`echo $line | tr -s '' $i` 	
#`echo $new >> mod_IBAN.txt` 	
echo $line | tr -s '[]' '[$i]' >>mod_IBAN.txt 	
let i=i+1 done    

PLease hELP !!!!

I tried to re-format (it was one long sentence) into something more readable.