No , it is not going to like that . It stops gathering verbatim lines only if the ending line is exactly of a certain kind , and end is not of that kind . Perhaps this ? documentclass usepackage usepackage lstset % backgroundcolorcolor , % choose the background color you must add usepackage or usepackage should come as last argument basicstylesmallttfamily , % the size and fonts that are used for the code breakatwhitespacefalse , % sets if automatic breaks should only happen at whitespace breaklinesfalse , % sets automatic line breaking captionposb , % sets the captionposition to bottom columnsfixed , % anything else is an abomination % commentstylecolor , % comment style % deletekeywords , % if you want to delete keywords from the given language escapeinside , % if you want to add LaTeX within your code extendedcharstrue , % lets you use nonASCII characters for 8 bits encodings only , does not work with UTF 8 framesingle , % adds a frame around the code keepspacestrue , % keeps spaces in text , useful for keeping indentation of code possibly needs columnsflexible % keywordstylecolor , % keyword style language , % the language of the code % morekeywords , ., % if you want to add more keywords to the set numbersleft , % where to put the linenumbers possible values are none , left , right numbersep 5 pt , % how far the linenumbers are from the code numberstyletiny , % the style that is used for the linenumbers rulecolorcolor , % if not set , the framecolor may be changed on linebreaks within notblack text e . g . comments green here showspacesfalse , % show spaces everywhere adding particular underscores it overrides ' showstringspaces ' showstringspacesfalse , % underline spaces within strings only showtabsfalse , % show tabs within strings adding particular underscores stepnumber 2 , % the step between two linenumbers . If it ' s 1 , each line will be numbered % stringstylecolor , % string literal style tabsize 2 % sets default tabsize to 2 spaces % titlelstname % show the filename of files included with lstinputlisting also try caption instead of title usepackage begin lipsum begin Test This is a test . This is only a test . Do not adjust your PDF reader . end lipsum end