What to say if you see someone afflicted by misfortune
الحَمْدُ لِلَّهِ الذِي عَافَانِي مِمَّا اِبْتَلَاكَ بِهِ وَفَضَّلَنِي عَلَى كَثِيرٍ مِمَّنْ خَلَقَ تَفْضِيلًا
(All praise is for Allah Who saved me from that which He tested you with and Who most certainly favoured me over much of His creation.)
Fortress of the Muslim (Hisn al-Muslim), Sa'id al-Qahtani.