How not to loop an array

I realised that the first line of this function will always make it always return “No such contact” if the name passed isn’t the first array item. I have a surface understanding of this. Can someone please explain further?