Yes when a byte is transmitted, TI bit will become 1, so you should wait untill TI become high. As Ian mentioned instead of while(!TI=0) it should be either
while(!TI); or while(TI == 0);
Also there is slight problem is seeing that one additional closing curly bracket just in the end of SBUF=fname[z]; statement. you require to remove this , otherwise for loop will contentiously update the SBUF register before the data get transmitted, without checking the TI bit