You have a number of potential problems. For instance, you aren't testing to see if the file opened. Neither are you testing your various input functions for success. Those things are NOT guaranteed to work. They will either work OR inform you of failure. You need to ask.

Further, do not use "gets". It is suceptible to buffer overrun. I would normally recommend fgets as a replacement, but this is C++. Use a C++ function.

Also, when you use something like "cin >> ch;" you will leave things in the buffer. If you don't handle this properly, subsequent input will not work properly.

I would also suggest that you use the string class instead of C strings. You'll have fewer problems.

While this is not a requirement, I highly recommend that you set your tabs to something like 4 spaces and instruct your editor to replace tabs with spaces. Your code is moving off to the right 4,000 miles for no good reason; it detracts from readibility, not adds to it. Having to scroll horizontally just sucks.