Are you sure you used ios::in instead of ios::app in line 51?
When you open the file for reading, are you sure the file exists?
After open, use is_open to check if you really opened the file.
Otherwise, post the code that doesn't work and tell us what line doesn't work.
However, note that your code won't work for strings containing spaces.
Furthemore, I suggest you to use std::string instead of char arrays.