Abu Hurairah narrated that:
The Messenger of Allah said: “Whoever sees an afflicted person then says: ‘All praise is due to Allah who saved me from that which He has afflicted you with, and blessed me greatly over many of those whom He has created, (Al-Hamdulillahi Alladhi Afani Mimmabtalaka Bihi Wa Faddalani Ala Kathirin Mimman Khalaqa Tafdila)’ he shall not be struck by that affliction.”