#include <iostream>
#include <fstream>
#include <cstdlib>

using namespace std;

ifstream f;
char nazwa[256];
string wiersz;

int main()
{
    cout << "Podaj nazwe pliku: ";
    cin >> nazwa;
    f.open(nazwa);
    if(!f.is_open())
	{
		perror(nazwa);
		exit(EXIT_FAILURE);
	}
    int i = 1;
	while(getline(f, wiersz))
	{
		cout << i++ << ": " << wiersz << endl;
	}
	if(f.bad())
		perror(nazwa);
	f.close();
    return 0;
}

