The following example demonstrates how to use getline function to read user's input and how to process file line by line.
en.cppreference.com