THE MITZVAH TO WRITE A SEFER TORAH
(R. Yehoshua bar Aba): One who buys a Sefer Torah is like one who seized a Mitzvah from the market. If he wrote a Sefer Torah, it is considered as if he received it from Sinai.
(Rav Sheshes): If he corrected even one letter, it is considered as if he wrote it.
Sanhedrin 21b (Rabah): Even if one inherited a Sefer Torah, it is a Mitzvah to write one himself - "Kisvu Lachem Es ha'Shirah ha'Zos".
Question (Abaye - Beraisa): It is not enough that a king inherited a Sefer Torah. (He must write one for himself.)
Inference: This applies only to a king!
Answer: No, the only difference about a king is that he must write a second Sefer Torah.
The Rif (Hilchos Sefer Torah 2:2) brings the Gemara in Menachos.
Nimukei Yosef: One who buys it gets a smaller reward than one who toiled to write it. This allows Midas ha'Din to say that had he not done it without toil, he would not have toiled to fulfill it. If one toiled to prepare the parchments and hired a Sofer and bore the burden until it was written. It is as if he wrote it. Hash-m considers that he would have toiled to go to the Midbar to receive Torah.
Rambam (Hilchos Sefer Torah 7:1): It is a Mitzvas Aseh for every man in Yisrael to write a Sefer Torah for himself. It says "write this Shirah' i.e. the Torah, which contains Shiras Ha'azinu, for we do not write individual Parshiyos. Even if one inherited a Sefer Torah, it is a Mitzvah to write one himself. If he himself wrote it, it is considered as if he received it from Sinai. If he does not know how to write, others write for him. If he corrected even one letter, it is considered as if he wrote it.
Rambam (Hilchos Melachim 3:1): If a king's father did not leave a Sefer Torah for him, or if it was lost, he must write two Sifrei Torah.
Rosh (Hilchos Sefer Torah 1): If one corrected even one letter, it is as if he wrote it, for the previous owner was forbidden to keep it uncorrected. The Mitzvah to write a Sefer Torah was for previous generations, which learned from it. Nowadays we leave a Sefer Torah in the Beis ha'Keneses for the Tzibur to read. Nowadays it is a Mitzvas Aseh for every Ish Yisrael to write Chumashim, Mishnah, Gemara and their explanation, for him and his sons to learn from. The Mitzvah to write a Sefer Torah is in order to learn from it - "v'Lamdah Es Bnei Yisrael Simah b'Fihem." Through Gemara and the explanations, one knows the Mitzvos clearly. Therefore, these are the Seforim that one must write and not sell, if not to learn Torah or get married.
Darchei Moshe (YD 270:1): The Mordechai (Hilchos Ketanos 957) says that it is as if he wrote it, for he caused no loss to the seller, rather, he saved the seller from the Aveirah of keeping an errant Sefer in his house!
Taz (YD 270:1): According to this, also if he bought a Sefer Torah from a Nochri who bought it from a Yisrael, it is as if he wrote it.
Shulchan Aruch (YD 270:1): It is a Mitzvas Aseh for every man in Yisrael to write a Sefer Torah. Even if his fathers left one for him, it is a Mitzvah to write his own.
Beis Yosef (DH u'Mah she'Chosav v'Ein): The Tur (OC 153) permits an individual to sell his Sefer and use the money for for anything. Some say that the Tur says so according to the Rosh (Hilchos Sefer Torah 1), who says that nowadays there is no Mitzvah to write a Sefer Torah, but according to the Gemara it is forbidden. I disagree; even the Rosh agrees that nowadays there is a Mitzvah to write a Sefer Torah. Also the Mordechai (Megilah 824) says in the name of Avi ha'Ezri that an individual may sell his Sefer Torah, just he will not see Berachah from this. The Rosh (Megilah 4:1) agrees. He says that an individual who sells his Sefer Torah is like the seven leaders of the city selling in the presence of the residents.
Pardes David (Ki Tetzei Daf 198, cited by R. Akiva Eiger): Toras Chayim says that one should not be Makdish his Sefer Torah to the Tzibur, for then it is not his and he was not Yotzei. We require "write for yourselves", that it is always his, just like for the Arba'ah Minim. Do not say that it suffices to write a Sefer Torah. Surely, if one wrote one and it was lost, he must write another. The Rambam says that if a king's father did not leave a Sefer Torah for him, or if it was lost (or stolen or faded - this is not in our text of the Rambam), he must write two Sifrei Torah. Similarly, in such a case a commoner must write another Sefer Torah, for this is like the Sefer Torah that the king stores away (just a king must have another Torah that always accompanies him). According to Toras Chayim, it is astounding that people write a Sefer Torah and are Makdish it (donate it to the Beis ha'Keneses). They think that they do a big Mitzvah, but they do not! However, Toras Chayim's law is not clear to me. Why didn't the Rambam teach only about a king who lost his Sefer Torah? It seems that a commoner who lost his Sefer was Yotzei and need not write another. This is unlike one who inherited a Sefer Torah, for he did not write it himself. A king was not Yotzei for it says "it will be with him", and it says "and he will write." If a Chevra Kadisha wrote a Sefer Torah together, I am unsure whether they were Yotzei. Rabah holds that one who inherited must write a Sefer Torah, due to "Lachem". If so, it must be totally his, and not a partnership, just like regarding Esrog. People assume that one is Yotzei this way. Or, perhaps here is different, for "write for yourselves includes partnership, like we say about Tzitzis. If not, it should have said 'for yourself.' Esrog is different, for it needed to say "take" in the plural "ul'KachTeM" to teach about Lekichah TaMah (complete).
Rema: If one hired a Sofer to write one for him, or bought it, and there was a mistake and he corrected it, it is as if he wrote it. If he bought it and did not correct anything, he is like one who seized a Mitzvah from the market, and he was not Yotzei.
Taz (1) and Gra (3): The primary opinion is of Rashi, that he was Yotzei, just not in the best way.
Shulchan Aruch (2): Nowadays it is a Mitzvah to write Chumashim, Mishnah, Gemara and their explanation, and he may sell them only to learn Torah or get married.
Beis Yosef (DH v'Chosav): How can the Rosh exempt one from writing a Sefer Torah, and exchange the Mitzvah for Chumashim, Mishnah, Gemara and their explanation? His only distinction between previous generations and this generation is that now we leave it in the Beis ha'Keneses. If so, he should say that also we must write a Sefer Torah and learn from it! Therefore, I say that he only comes to add a Mitzvah for us to write these other Seforim, and an Isur to sell them. This is a greater Mitzvah than writing a Sefer Torah. Surely the primary Mitzvah is to write a Sefer Torah, and he and his sons will learn from it, like in previous generations. R. Yerucham says that the Ge'onim say like the Rosh.
Rebuttal (Prishah 2 and Drishah 4): The Rosh says that since nowadays we learn from other Seforim, there is (only) a Mitzvah to write them, He did not say that it is also a Mitzvah to write them! Previously, it was forbidden to write Oral Torah, so we needed to learn from a Sefer Torah with the proper crowns on letters (from which R. Akiva used to expound Halachos), the proper missing and extra letters, and musical notes. In CM 93, the Tur wrote in the name of Ri Bartzeloni that we force a borrower to sell his Seforim, even a Sefer Torah. The Tur did not comment (that the Rosh holds that nowadays other Seforim are more essential for us) because that is not the primary place for this law. Alternatively, regarding paying a debt it is a bigger Chidush that one must sell his Sefer Torah.
Taz (4 and Gra 4): The Beis Yosef's Perush is primary. The Magid Mishneh agrees.
Beis Yosef (DH Mitzvas): We hold (Gitin 60a) that one may write only complete Seforim of Tanach. (Perhaps one may write a partial Chumash in order to teach a child, but this does not apply here.) Therefore, the command 'write this Shirah' cannot refer to Shiras Ha'azinu. It must refer to the entire Torah.