Minor modification in cpp file
Add if condition for empty input string