Logical program for not getting indeterminate value

This is giving me indeterminate value. Although I am excluding the indeterminate value by using If statement in line 6. Can anyone help me to correct this logic? Show me where is the problem?

Beware that Subscript[yi, 1,1]!=0 does not give False. You should use Subscript[yi, 1,1]=!=0 for that.

Thank you. I am new to this. Can you tell me what is the difference between != and =!= ?

In very simple cases, like 2!=3, the answer is immediately True, but usually != is meant for further processing, like equation solving. x-1!=0 is solved as x!=1. By itself, x-1!=0 is left as it is.

The test for literal inequality is =!=. It has a different purpose. x-1=!=0 gives True, because the two sides are not the same expression.

Check out the documentation about Unequal and UnsameQ.