The Talmud, Tractate Bava Batra 15b, asks your question. Who wrote the last eight verses of the Torah which describe Moses's death? The Talmud offers two answers.
According to one opinion, Joshua wrote them. According to the other opinion, Moses himself wrote them using tears instead of ink. After Moses died, Joshua traced over the letters with ink. Some explain the Talmud to mean that Moses wrote the last eight verses not with tears, but rather in a jumbled fashion. In Hebrew, the word for "tears" (dima) is spelled the same way as the word "jumbled" (dema). That is, Moses wrote the last eight verses with no spaces to differentiate between the end of one word and the beginning of the next. It was left to Joshua to split up the words.