SIRTUT FOR A SEFER TORAH, TEFILIN AND MEZUZOS
Gemara
16b - R. Tanchum: "Divrei Shalom v'Emes" - the Megilah requires Sirtut (lines scratched in the parchment to ensure that the writing will be straight) like the Emes of Torah (this will be explained).
18b (Beraisa - R. Yirmeyah): Tefilin and Mezuzos do not require Sirtut.
The Halachah is, Tefilin do not need Sirtut, but Mezuzos do.
Menachos 32a - Beraisa: Worn parchments of a Sefer Torah or Tefilin may not be used for a Mezuzah, for we do not demote something Kodesh to a lower Kedushah.
Question: Even if it was permitted to demote Kedushah, the parchments could not be used for a Mezuzah!
Mezuzah requires Sirtut, but Tefilin (Tosfos - and Sifrei Torah) do not require Sirtut (therefore, normally they do not have Sirtut)!
Rav: A Mezuzah without Sirtut is Pasul.
Rav Minyamin bar Chilkiyah: A tradition from Sinai requires Sirtut in a Mezuzah.
Answer: Tana'im argue whether or not a Mezuzah requires Sirtut (R. Yirmeyah does not require it).
Rav Yehudah: If a Mezuzah was written like an Igeres (letter), it is Pasul.
Question: What is the reason?
Answer: We learn a Gezerah Shavah Kesivah-Kesivah from Sefer.
Rishonim
Rif (Hilchos Sefer Torah (printed after Menachos) 4b): The Yerushalmi cites a tradition from Sinai that requires Sifrei Torah to be written with ink on hide that is Mesurgal...
Nimukei Yosef: 'Mesurgal' means with Sirtut.
Rif (Megilah 5b and Hilchos Tefilin 5a): The Halachah is, Mezuzah requires Sirtut, but Tefilin does not.
Ran (Megilah 5b DH v'Hilchesa): Perhaps this is because Mezuzos are checked twice every seven years (therefore the writing should be very straight), whereas Tefilin are checked only once every Yovel. According to this, Seforim need Sirtut because we read in them constantly, and uneven writing could cause the reader to go to the wrong line.
Ran (ibid.): R. Tam requires Sirtut only for the top line in a Sefer Torah, because R. Yitzchak (always) forbids writing even three words without Sirtut (Gitin 6b). All the more so, this suffices for other Seforim. If all Kisvei ha'Kodesh required Sirtut on every line, we would not need a tradition from Sinai to teach about Mezuzos, and surely we would not be more lenient regarding Tefilin! We learn from "Divrei Shalom v'Emes" that Megilah needs Sirtut like the 'Emes of Torah'. This refers to a Mezuzah. It cannot mean a Sefer Torah, for we already learned that a Megilah sewn with linen threads is Pasul because it is called Sefer, so we would not need another verse to teach about Sirtut.
Rebuttal (Ran): Perhaps all Kisvei ha'Kodesh require Sirtut on every line, lest the reader go to the wrong line. Since Mezuzos and Tefilin are not read, they should not need Sirtut; a tradition requires Sirtut for Mezuzos. Rashi explains that the 'Emes of Torah' is a Sefer Torah; the Yerushalmi supports him. Also, the Yerushalmi says that a Sefer Torah must be 'Mesurgal', i.e. with Sirtut between every two lines. We could not learn Sirtut from the fact that it is called Sefer, for it is also called Igeres. One might have thought that it is called Sefer regarding the primary aspects of writing it, i.e. Klaf and ink, but not regarding Sirtut, which is merely to beautify the writing.
Nimukei Yosef (DH Ein Tzerichin): Tefilin does not require Sirtut because it is written on Klaf (which is thin), and Sirtut might tear the Klaf. Tosfos requires a line at the top because even three words require Sirtut.
SMaG, brought in Shiltei ha'Giborim (8): Perhaps R. Tam requires lines (in Tefilin) also on bottom and to the sides.
Rambam (Hilchos Tefilin 1:12): A tradition from Sinai requires Sirtut for a Sefer Torah or Mezuzah. Tefilin do not require Sirtut, for they are covered.
Kesef Mishneh: Mezuzos are not as covered as Tefilin, for Mezuzos can easily be removed from their place.
Rosh (Hilchos Sefer Torah 7 (after Menachos)): A Beraisa teaches that we may not use parchments of a Sefer Torah or Tefilin for a Mezuzah because a Mezuzah is less Kodesh. The Gemara (Menachos 32b) asked, in any case it is not possible because a Mezuzah requires Sirtut! R. Tam (in Tosfos DH Ha) infers that a Sefer Torah does not require Sirtut. We did not establish the Beraisa to discuss when Sirtut was done, for it is lowly to do something from which one is exempt. 'Mesurgal' means that there is a Sirtut on top, for one may not write three or four words without Sirtut. It does not mean that there is Sirtut between every two lines. It is good to do Sirtut for a Sefer Torah to beautify the writing - "Zeh Keli v'Anvehu". This is not needed for Tefilin, since they are covered in boxes.
Rosh (ibid.): It appears that the Halachah follows Rashi, who requires Sirtut for a Sefer Torah. The Yerushalmi learns Sirtut for Megilah from a Gezerah Shavah from "Emes Keneh v'Al Timkor", which refers to Torah. The Gemara asked why parchments of Tefilin may be used for a Mezuzah, since they lack Sirtut. Similarly, it asked about closed Parashiyos only regarding (demoting) a Sefer Torah, and it asked about Klaf only regarding Tefilin. Even regarding Tefilin, it is good to make Sirtut if one cannot write straight without it. He is not called a 'Hedyot' for doing something from which he is exempt.
Rosh (Hilchos Mezuzah 7): Rashi (Menachos 32b DH Kosvah) explains that a Mezuzah written like an Igeres is Pasul, i.e. it lacks Sirtut. Alternatively, it is not precise concerning extra or missing letters. The latter explanation is better, for a tradition from Sinai Gezeirah teaches about Sirtut, and a Gezerah Shavah disqualifies 'k'Igeres'.
Rashi (Menachos 32b DH Kesivah) explains that the Gezeirah Shavah is from Sefer Kerisus (a Get), or from a Sefer Torah. Tosfos (DH Kosvah) says that it is from Megilas Sotah.
Poskim
Shulchan Aruch (32:6): It suffices to have Sirtut on the top line of Tefilin. If he cannot write straight without Sirtut he should have Sirtut for every line.
Beis Yosef (DH v'Sefer): R. Simchah disqualifies if Sirtut was done. This is difficult. The Gemara said that it is not needed, and that one is called a Hedyot for doing something from which he is exempt, but not that it disqualifies! Mahari Avuhav says that it could disqualify because it is extra. Nevertheless, the consensus of the Poskim is that it does not disqualify.
Bach (DH u'Mah she'Chosav Tov): The Tur says that if one cannot write straight without Sirtut it is good to have Sirtut for every line. If he did not, the Tefilin are Kosher even though the writing is crooked. The Tur holds that no one is called a Hedyot for making Sirtut, even if he does not need it. The Gemara (Menachos 32b) did not answer that the parchment happened to have Sirtut, because optional Sirtut (of Tefilin) does not suffice for an obligatory Sirtut (of Mezuzah), just like tanning l'Shem Mezuzah (according to the opinion that it is unnecessary) does not help for Tefilin, which require tanning Lishmah.
Mishbetzos Zahav (4): The Bach requires Sirtut Lishmah. This is unlike the Shach, who says that it need not be Lishmah in a Sefer Torah, and the same applies to a Mezuzah.
Mishnah Berurah (20): One line on top enables writing all the lines straight.
Rema: Some say that even one who can write straight without it must have Sirtut on top and bottom and on the sides.
Bi'ur Halachah (DH Ein): If there is not even one line on top (according to the Mechaber, or on all the sides according to the Rema) R. Tam is Posel, and the others say that it is Kosher.
Shulchan Aruch (ibid.): One should not use lead or anything else that marks the parchment for Sirtut.
Mishnah Berurah (22): Some say that b'Di'eved a Sirtut that marks does not disqualify. Some say that if it is black it could 'join' letters, and it will be considered that they are touching, which disqualifies.
Shulchan Aruch (YD 271:5): A Sefer Torah requires Sirtut. If it was written without Sirtut it is Pasul.
Gra (15): All the Poskim hold like Rashi, who requires Sirtut for a Sefer Torah.
Shulchan Aruch (ibid.): One should not use lead or anything else that colors the parchment for Sirtut.
Source (Gra 16): The Yerushalmi and Maseches Sofrim (1:1) say that a reed should be used. This does not exclude a knife; it excludes only (things that mark like) lead.
Beis Yosef (DH Kosav Od): The Mordechai is unsure whether or not Sirtut must be permanent (e.g. using an iron blade), or if it suffices that it is visible at the time of writing (e.g. lead that will get erased later), or if a permanent marking (e.g. ink) is permitted. It appears that 'Sirtut' denotes a groove.
Pischei Teshuvah (14): If a mistake was made and it was erased and the Sirtut was erased, and the correction was written without Sirtut it is Kosher, because the scribe can see from the erasure how to write straight.
Shulchan Aruch (288:8): A Mezuzah requires Sirtut. If it was written without Sirtut it is Pasul.