# linebreaks in lstlisting and verbatim environment

longline*.txt files contain some text and in some files the text is inserted in an environment as indicated in the filename.

The following script:

\documentclass{article}
\usepackage{listings}
\begin{document}
\input{longline.txt}

\input{longline_verbatim.txt}

\input{longline_lstlisting.txt}

\end{document}


reveals a different rendering of the text:

The actual text contains characters such as _ and the lstlisting and verbatim environments are evaluated as a rescue.

The problem is that the paragraph is not broken down into lines in the verbatim and lstlisting environment.

How to solve the problem?

\documentclass{article}
\usepackage[cp1251]{inputenc}
\usepackage[english]{babel}
\usepackage{listings}
\usepackage{lipsum}

\begin{document}
\lipsum[1]

\lstset{
linewidth=\linewidth,
breaklines,
breakatwhitespace=true,
breakindent=0pt,
basicstyle=\fontsize{9}{11}\usefont{T1}{cmr}{m}{n}\selectfont
}
\lstinputlisting{long.txt}
\end{document}


The file long.txt contains plain text divided into paragraphs:

And the result: