With regards to the student of knowledge never ceasing to watch carefully over his niyyah when doing good deeds, the Shaykh Saalih al Fawzaan hafidhahullaah mentions after quoting the hadeeth of the first people to be judged on the Day of Resurrection and that they will be cast into the Hellfire due to the corrupt intention behind their good deeds:
So this (hadeeth) is from that which emphasises to the Muslim that he must make his intention purely and sincerely for Allaah, the Mighty and Majestic, whenever he establishes any act from the good deeds, such as prayer and fasting and the Hajj and ‘Umrah, and giving charity, and the seeking of knowledge and teaching it, and enjoining the good and forbidding the evil, and calling to Allaah, the Mighty and Majestic – and other than that.
Therefore, it is befitting that he constantly watch over his intention and that he try to remember his intention in every action he does, in that he makes it purely and sincerely for Allaah and that he drives away ar riyaa- (doing good deeds for show) from himself. (This is) because the person is a human being, and there occurs to him (the temptations of) showing off and love of being acclaimed and love of being praised.
So it is upon him to drive this (corrupt) intention away when it comes upon him and to make his intention purely and sincerely for Allaah, the Mighty and Majestic.
((Al minhat ul rabbaaniyah page 22 of Shaykh Saalih al Fawzaan hafidhahullaah, translated by Nasser ibn Najam)
 Reported by at Tirmidhee (2382), Ahmad in his Musnad (2/321) and others from the hadeeth of Aboo Hurayrah radi Allaahu ‘anhu.