וּכְתַבְתָּ֛ם עַל־מְזוּז֥וֹת בֵּיתֶ֖ךָ וּבִשְׁעָרֶֽיךָ׃
Tuliskanlah semuanya itu pada tiang-tiang pintu rumahmu dan pada pintu-pintu gerbangmu,
Bartenura
יחזור למקום שטעה – If between each section [of the Shema] he erred and did not know on which section he had interrupted (the appropriate order), and to which paragraph’s beginning he should return to, he should go back to the first interval – which is “והיה אם שמוע” (Deuteronomy 11:13-21). And Maimonides states that this is the first sentence: “ואהבת את ה' אלהיך” (Deuteronomy 6:5), and if he is in the middle of a section, he should stop [assuming that] he knows which section (of the Shema) that he is in, but if he doesn’t know which place and from which section he is in, he should stop and return to the beginning of that section. If he was reciting: “וכתבתם [על מזוזות]” and did not know if it was referring did not know if it was referring to “and you shall inscribe them” from the first section of the Shema (Deuteronomy 6:9) or the second section of the Shema (Deuteronomy 11:20), he should go back to the first mention of “you shall inscribe them” (Deuteronomy 6:9). But if he became doubtful after he had begun (the concluding verse of the second section of the Shema), “to the end that you and your children may endure” (Deuteronomy 11:21), he should not go back, since he is following the natural flow of the language [of the Shema].
Or HaChaim
למען ירבו ימיכם, "that your days may multiply, etc." Why did Moses not write this verse prior to verse 20, i.e. the writing down of this paragraph and attaching it to the doorposts? If that had been the case our verse and the blessing it contains would also be part of the promise in what was to be attached to the doorposts? Perhaps Moses chose this order in order to teach us that the fulfilment of the commandment in verse 20 would bring in its wake the blessing contained in verse 21. This may be what the Talmud (Shabbat 32) had in mind when it stated that "anyone who takes the commandment of the Mezuzah seriously has his lifespan extended." [The only quotation I was able to find on that folio was that neglect of the commandment of Mezuzah may result in premature death. This itself is questionable. Ed.]