Sayyiduna Abdullah bin Amr (may Allah be pleased with him) narrates: The Noble Prophet (peace and blessings of Allah be upon him) said: "Whoever goes to the mosque near him for congregational prayer, then one of his two steps erases a sin and the other step records a good deed. This happens both when he goes and when he returns." (Imam Ibn Hibban, may Allah have mercy on him, says:) Among the Arabs, sometimes an action is attributed to the original matter. Just as they attribute it to the doer, similarly, sometimes the action is attributed to the act itself, just as it is attributed to the command. So Sayyiduna Abdullah bin Amr (may Allah be pleased with him) has informed that the Noble Prophet (peace and blessings of Allah be upon him) shaved his head at the time of the Farewell Hajj, meaning that the one who shaved (the barber) did so; it does not mean that the Prophet (peace and blessings of Allah be upon him) did it himself. So here, the action is attributed to the command, just as it is attributed to the doer. Whereas, regarding the narration transmitted from Sayyiduna Abdullah bin Amr (may Allah be pleased with him) which we have mentioned earlier, that one step erases a sin, here the action is attributed to the act itself. Because the step does not erase the existence of the sin, rather Allah Almighty bestows this favor upon the servant.
Hadith Referenceصحیح ابن حبان / كتاب الصلاة / 2039
Hadith Gradingفضيلة الشيخ الإمام محمد ناصر الدين الألبانيحسن - «التعليق الرغيب» (1/ 125).فضيلة الشيخ العلّامة شُعيب الأرناؤوطإسناده حسن، رجاله رجال الصحيح غير حُيَيّ بن عبد الله المعافري، وثقة ابن معين وغيره، وضعفه أحمد وغيره، وقال ابن عدي: أرجو أنه لا بأس إذا روى عنه ثقة.