You already show that you can do step 1.
Step 2 is merely a variation of what you already do too.
Step 3, seriously, do you claim that you have never encountered a control structure that can repeat statements?
this is what i have now. . . all i need is to number each line from here,
#include <iostream>
#include <fstream>
#include <string>
using namespace std;
int main()
{
ifstream file;
string input, String;
int a = 0;
string prev_line = "";
int counter = 0;
cout << "Enter filename" << endl;
cin >> input;
file.open(input.c_str());
if (!file)
{
cout << "File not found." << endl;
return 0;
}
while(a < 1) // To get you all the lines.
{
getline(file, input); // Saves the line in STRING.
if (input != prev_line)
{
prev_line=input;
cout<< input <<endl; // Prints our STRING.
}
counter++;
// initialize line number to 1
while( getline(file, input) ) // for each line in the file
{
// print line number
// print the line (input)
// print a newline
// increment line number
}