Use char* in place of string with getline() method. It should work.
I do not think if you are using Lotus version you need the if statement "if(line.length() > 0)
", it will just increase the run time and size of code than it will do the good.
Its good idea to use Lotus version of while statement while(!getline(cin,line).eof())
. It will reduce the compexcity of code as will as improve the performance and save you to overhead of handle error.