while str
str = bufferReader.readLine
session_id = str.strip.scan(/SessionId: (.+)\s/)[0][0] if str.include?("SessionId: ")
if session_id
# session_id found
else
# session_id not found
end
end
There is actually no need to loop through the lines. You can just read the file and use regular-expression to find required text. But whatever suits your cat. Sometimes reading whole file could be really problematic if it is too big.
HTH