On second thought, it's a bit unclear what you are trying to achieve. Do you want to get only the line that ends with a particular character/substring?
In this case you could use a combination of
getline() to get a line from a text file,
rfind() to find the last occurence of a character/substring,
and size() (for example) to test if the substring is at the very end of the string.