Your problem is in
if (ins.fail (fileName.c_str()))
You just need
if (ins.fail)
and you will probably want to change
cerr << "Error: Unable to open file : FILENAME" << endl ;
to something like
cerr << "Error: Unable to open file : " << filename.c_str() << endl ;