\documentclass{article}
\usepackage{moreverb}
\begin{document}
\begin{verbatimwrite}{Hello.tex}
\documentclass{article}
\begin{document}
 Document \LaTeX.
\end{document}
\end{verbatimwrite}

Document écrit...
\end{document}
