# Include a text file as a paragraph

I am trying to input a text file to latex. However, this text file contains special symbols like % and & which causes issues. I do not want to import the file as verbatim, it should be imported like regular text with paragraph formatting and word wrap.

Minimal approach:

\documentclass[]{article}

\newcommand\inputtextfile{}
\newcommand\redefinecharacter{}
\protected\def\redefinecharacter#1#2%
{%
\catcode#1=13
\begingroup
\lccode\~=#1
\lowercase{\endgroup\def~{#2}}%
}
\protected\def\inputtextfile#1%
{%
\begingroup
\redefinecharacter{\\}{\textbackslash}%
\redefinecharacter{\{}{\{}%
\redefinecharacter{\}}{\}}%
\redefinecharacter{\$}{\$}%
\redefinecharacter{\&}{\&}%
\redefinecharacter{\#}{\#}%
\redefinecharacter{\^}{\^{}}%
\redefinecharacter{\_}{\_}%
\redefinecharacter{\%}{\%}%
\redefinecharacter{\~}{\textasciitilde}%
\input{#1}%
\endgroup
}

\begin{document}
The output of our file doesn't look too good, because we input something that
contains code as text :)

\inputtextfile{\jobname}
\end{document}
`

Ugly output: