Moshe and Bilaam.
Moshe wrote his book and the portion of Balaam. He also wrote the book of Job ( Bava Basra 14b-15a) .
Moshe wrote the Pentateuch and went back ans wrote the book of Balaam (Yerushalmi Sota (5,6).
Why must we be specifically told that Moshe wrote the portion of Balaam; is it not a part of the Chumash and already included in the phrase "Moshe wrote his book"?
A number of answers to this perplexing question have been offered. As we consider them, let us be aware of the implications of these answers to how the Torah was written and what it tells us about what was canonized and what was not.
1. Ritva ad. loc. suggests that there was in existence a Book of Balaam of which Chazal were aware but which was not included in the canon and did not survive. This is in itself not surprising for Tanach itself mentions dozens of works that we no longer possess, i.e. Book of Yashar, Chronicles of the Kings of Judah etc . Presumably, the lost Book of Balaam documented the story or the prophecies of Balaam in greater detail than the Chumash.
This answer also apparently assumes that canonization was not automatic; just because Moshe wrote a book does not mean that it is a part of Scripture or must be preserved.
This answer is also offered by Drashos Ibn Shab, p. 47 and cited by the Shelah (p. 66) in the name of R.Menachem Tsioni. This answer is supported by a textual variant quoted in Dikdukei Sofrim that reads "Book of Balaam" instead of "portion of Balaam".
2. Others propose that the portion of Balaam refers to Joshua 13:15-33, which reviews the story of Balaam. This implies that Mosaic fragments can be found in other Biblical books, a view that had been a subject of significant controversy at one time . This answer is offered by R. Menachem Azariah DiFano in Imros Tohoros, p. 130 and R. Noson Spira in Megale Amukos, 118.
3. R. Z. H. Chajes in Darkei Moshe (Kol Sifrei Maharitz Chayos, 1, 474) suggests that this portion of Balaam is found in Job. He calls attention to the different wording of our statement found in Yerushalmi Sotah, where it says, "Moshe wrote his book and came back and wrote the book of Balaam". This, in R. Chajes opinion, refers to Elihu ben Berach'el, the friend of Job, identified in the Yerushalmi as the same person as Balaam. Moshe completed the Chumash and then "went back" and wrote the Book of Job, in which Elihu = Balaam was one of the protagonists.
4. Dr. Shneur Leiman in his Canonization of Hebrew Scriptures, Connecticut Academy of Arts and Sciences, 1991, p. 164, fn. 260, cites Josephus who seems to have been cognizant of this issue. Josephus is apparently troubled by the fact that it may have been possible to deny Mosaic authorship of the Balaam narrative for it contains prophecies that Moshe did not receive and events of which he would not necessarily be aware. Josephus responds that on the contrary, Moshe's decision to preserve the story and prophecies of Balaam reflects Moshe's superior ethics. Presumably it is for this reason that the Talmud emphasizes that Balaam's portion was written by Moshe as was the rest of the Chumash.
"…this was the men to whom Moses did the high honor of recording his prophecies; and though it was open to him to appropriate and take credit for them to himself, as there would have been no witness, he had given Balaam this testimony and deigned to perpetuate his memory." (Antiquities, IV, 156).
This explanation directly contradicts Shelah's (Balak) explanation of Rashi in Bava Basra ibid. The Shelah writes: " Do not say that Moshe Rabbeinu received the story of Bilaam because the Holy One Blessed Be He informed him of it, as we learn the books of prophecy without being prophets ourselves and attaining what they attained. Rather Moshe attained what he attained through (his own independent) prophecy…"
5. Torah Shelema cites two other suggestions by recent authors but rejects them both. The first is that Balaam must have said his prophecies in some foreign tongue, such as Moabite, since they were intelligible to Balak, the king of Moab . Moshe had to transplate them into Hebrew- and this is what is meant by "Moshe said the portion of Bilaam". R. Kasher rejects this because the Torah reports many conversations and events that musth have been taken place in Arameic or Egyptian languages but that it translates for us. This is therefore more of a rule than exception and cannot explain this Talmudic passage. I would add that archeological discoveries such as the Mesha stone taught us that of all the surrounding languages Moabite appears to be the closes to Hebrew. It would be fully intelligible to a Hebrew speaker and should not require translation.
The other suggestion was made by a recent author in a work printed in the town of Satmar . He suggested that Moshe wrote an account of the events in the portion of Bilaam in a separate work. Later, the Men of the Great Assembly inserted it into the Torah. R. Kasher rejects this on ideological grounds for it contradicts the Rambam's 13 principle of faith.
5. One wonders whether there may not be moral lesson in this Talmudic passage. We know from other Midrashic sources  that Balaam was a great prophet, one in fact as great or even potentially grater than Moshe. Yet, he misused his gift of prophecy and brought himself and his students to ruin.
Although Balaam failed, a little bit of the potential good that he could have done was redeemed and captured by Moshe. Each one of us is meant to write a book with his life, a book in which he is the main character. Balaam did not fulfill the purpose for which his soul descended into this world. A portion of the book that Balaam was meant to write was instead written by Moshe.
Every man can learn from the story of the immensely gifted man who has gone to ruin. Moshe wrote the story of Balaam in his book so that it may serve as a warning and an example, so that we may know the awesome responsibility that comes with G-d given gifts and the terrible consequences of misusing them in the service of the self. Hashem's plans always come to fruition; if we refuse to comply with them, His book will still be written but by others and not by us.
 For discussions of this issue see, Leiman, cited in the text, R. M. Kasher, Torah Shelema, V. 19, p. 363-365, and A. J. Heschel, Torah Min Hashemaim, Vol. 2, p. 435-437.
 Leiman counts 24 such books (p. 17-18), although one is based solely on Septuagint, leaving 23 in the Masoteric text.
 In the year 5735, Rabbi Y, S, Langer brought out “Peirushe Hatorah L'R. Yehuda Hachasid” from a manuscript. This work consisted of explanations attributed to R. Yehuda Hachasid and collected and written down in decades subsequent to his passing. It is a heterogenous work, uneven in style and content and not authenticated by scholars of subsequent generations.
The book contains several suggestions of peculiar character and provenance. It is often difficult to understand the basis and precedent or some of the recorded remarks; among them are several that bear directly upon the issues that we are now discussing.
Among these is the surprising suggestion that the Song of the Well (Bamidbar 21,17) originally included the entire Hallel Hagadol (Tehilim 136) but that it was removed by David and incorporated into his Tehilim, as he also did with several other psalms originally composed by Moshe. Similarly, there are three other statements to the effect that certain verses in the Chumash were inserted by the Men of the Great Assembly. Curiosly, these statements appear to have neither the force of logical argument behind them nor do they truly resolve serious questions of pshat or structure; they seem almost intentionally inserted to some polemical purpose.
The matter was referred to the attention of R. Moshe Feinstein. In Igrot Moshe, Y”D, 3, 114 he judges the matter and concludes that the attribution to R. Yehuda Hachasid is mistaken or has been made with sinister motives. He quotes the passages in Sanhedrin and Rambam and deals with the correct text of a passage in Avot D'Rabbi Natan that bears on this issue. He concludes: ” We have it already an accepted law (on the authority)of Ibn Ezra that such a work should be burnt (in the comments to Genesis 36, 31) and now new books of this type are being printed. This book is even worse for the wicked heretics falsified in it views that they attribute to R. Yehuda Hachasid…it is worse than other heretical works which are not likely to be trusted by simple folk whereas the name of R. Yehuda Hachasid is ascribed to this work… and it leads the multitudes to sin”. R. Moshe then continues by questioning the reliability of the rest of the manuscript and advises that it should not be printed in its entirety.
Subsequently, it was pointed out to him that one of the offending remarks in this manuscript is also quoted in the name of R. Yehuda Hachasid by R. Menachem Tsiuni, an Italian commentator of 15 th century. R. Moshe responded that he most likely simply transcribed something that he discovered in some manuscript in the name of R. Yehuda Hachasid without giving it due consideration and that, perhaps, it would be best to withdraw that work as well .
One may restate R. Moshes's position as follows. The manuscript in question has never been authenticated as representing positions that R. Yehuda Hachasid truly held, neither had it been available for evaluation and criticism by subsequent generation of Torah scholars. It clearly contradicts an accepted, time hallowed principle of our faith. It must therefore be presumed to contain forgeries and not to be published.
This assumption of R. Moshe that an unknown heretic ascribed these views to the reknown R. Yehuda Hachasid received unexpected (and unintended) support when Professor I. Ta Shema published an article in which he identified a little known student of R. Yehuda Hachasid (1240-1160) who apparently held views similar to the ones ascribed to R. Yehuda Hachasid in the manuscript under discussion. He discovered in a manuscript of R. Shlomo ben Shmuel Hatsarfati, a student of various Ashkenazic rabbis in the generation after R. Yehudaj Hachasid and an author of various works extant primarily in manuscript form. In a series of notes on Chumash, he offers similar views in the name of R. Yehuda Hachasid.
The newest contribution to this discussion can be found in the last volume of Mishne Halachos of R. Menashe Klein, where he suggests that R. Yehuda Hashasid is not referring to the text of the Chumash that Moshe wrote and from which these passages were moved to new locations but to another work of Mosaic authorship that is now lost. This view comes very close to the one that we now discuss.
 See Sifri end of Bracha, Bamidbar Rabba 20, 1, Bareishic Rabbah 52,7.