to explicate Squashman's suggestion:
@echo off
setlocal enabledelayedexpansion
set "input_list=list.txt"
set "string=kkklllmmm"
set "output_list=output.txt"
(for /f "delims=" %%# in (%input_list%) do (
REM if current line is your searchstring, then echo the previous line:
if "%%#"=="%string%" echo !line!
REM set the variable to the current line:
set "line=%%#"
)) > "%output_list%"
Note: I used empty delimiter to read the whole line. If you intentionally used : for some reason (aside "some character that isn't in the file to read the whole line"), just reimplement it.
Edit:
How did you get the previous line? by setting the line variable after comparing %%#(the current line), so with each turn of the loop at the end line is the current line, but on the next turn at the beginning, it will be the "previous line" (and become the "current line" only at the end of the turn)
I need to find more than one string: a bit more complicated: add a second for to process each search string. Note the syntax of the set "string=..." line. To also process strings with spaces, this syntax is mandatory. (if there were no spaces, it would simplify to set "string=string1 string2 string3"), but to process the spaces, each substring has to be quoted too:
set "string="string 1" "string 2" "string 3"")
@echo off
setlocal enabledelayedexpansion
set "input_list=list.txt"
set "string="kkklllmmm" "xxx / yyy / zzz""
set "output_list=output.txt"
(for /f "delims=:" %%# in (%input_list%) do (
for %%a in (%string%) do (
echo %%#|findstr /xc:%%a >nul && echo !line!
)
set "line=%%#"
)) > "%output_list%"
The outer for (%%#) gets one line at a time.
The inner for processes each substring in the list at a time.
The next line echoes the line and tries to find the substring (switches
x=compare the complete line,
c=search for the literal string (including the spaces, else it would try to find each word in the string, e.g. xxx, /, yyy etc.)
&& executes the command echo !line! only, if the previous command succeeded (findstr found a match)