You can use std::getline to read a line from the file. Read each line until you find a line that contain the word. You can use std::string::find to check if a line contains the word. You also need to keep track of how many lines you have read so that you can output the line number when the word has been found.