Musar for Avodah Zarah 38:8
שנוי בנביאים דכתיב (יהושע א, ח) לא ימוש ספר התורה [הזה] מפיך והגית בו יומם ולילה למען תשמור לעשות ככל הכתוב בו כי אז תצליח את דרכיך ואז תשכיל משולש בכתובים דכתיב (תהלים א, ב) כי אם בתורת ה' חפצו ובתורתו יהגה יומם ולילה והיה כעץ שתול על פלגי מים אשר פריו יתן בעתו ועלהו לא יבול וכל אשר יעשה יצליח
It is repeated in the Prophets, for it is written, “This book of the Torah shall not depart from your mouth, but you shall meditate upon it day and night, that you observe to do according to all that is written in it; for then you will make your ways prosperous, and then you shall have good success” (Joshua 1:8). It is mentioned a third time in the Writings, for it is written, “But his delight is in the Torah of the Lord, and in His Torah he meditates day and night. And he shall be like a tree planted by streams of water, that brings forth its fruit in its season, and whose leaf does not wither; and in whatever he does he shall prosper” (Psalms 1:2-3).