Reading from the file --------------------- You can read in the whole file using: string s; while (getline(infile, s)) { // blah blah } but it's probably easier to do one getline before the loop to read in the vertical word separately from the lines of the poem: mesostic meso; string s; getline(infile, meso.vert_word); // read the vertical word directly while (getline(infile, s)) { meso.poem_lines.push_back(s); } Finding the match_positions --------------------------- Use a loop for this. You can loop over either the letters (chars) of the vertical word, or the entire lines (strings) of the poem. It doesn't matter either way, since it's guaranteed there are the same number of chars in the vertical word as there are lines in the poem. Printing the mesostic with the correct spacing ---------------------------------------------- This is where you have to get a bit clever. The hint here is that the number of spaces to add to each line of the poem is dependent on more than just that single line --- the number depends on a factor that can only be deduced by examining the entire poem. Work out some examples (e.g., from the text files) on graph paper to figure out this algorithm. See if you can figure out what the connection is between match_positions and how many leading spaces are added to each line of the poem.