it gives result even if some characters in the "String s" matches the currentline.
As it should based on the String API. Think about it. If your agentId value is "XYZ" and there is some other value in the record which contains the value "WXYZ" how do you know contains(CharSequence) returned true from the desired field (in this case agentId) in the record.
You may want to rethink your approach. If this is structured data, maybe extract the agentId from a specific index range using the substring method or looking for certain delimiters to get the field position for agentId. If it's unstructured data then maybe do some further analysis to figure out how to extract the actual agentId field value.