[Tex/LaTex] remove unwanted contents from list of listings

inputlistingstable of contents

The following code adds a wrong line to the list of listings

enter image description here

\documentclass{scrbook}

\usepackage{listings}
\usepackage{filecontents}

\begin{document}

\begin{filecontents*}{democodefile}
\begin{Verbatim}[frame=lines]
Verbatim line.
\end{Verbatim}
\end{filecontents*}

\lstinputlisting{democodefile}%

\begin{lstlisting}
\begin{document}
\chapter{Introduction}
Some text ...
\chapter{Theory}
\end{document}
\end{lstlisting}

\lstlistoflistings

\end{document}

How can I prevent this entry?

Best Answer

Use the nolol=true option to remove that entry from the \listoflistings:

 \lstinputlisting[nolol=true]{democodefile}

This yields:

enter image description here