Maybe what's coming in at the COM port differs from the text file? Perhaps you could try logging what is read at the com port into a text file and then look through it for differences from what you're expecting.
If you write out to log immediately after the fgets then you can be reasonably sure of getting an accurate representation of what's coming in. Also unflushed data in buffers can be lost when the program crashes so make sure when logging you open the log file, write the data and close the log file - it'll slow the program down a bit but you'll be certain to see what comes in at the time the crash occurs.
Or if you don't have that much storage, write the data to screen but again make sure you flush the buffers to make sure that what is printed is displayed before the crash - I don't know how you do that with cout but if you use printf instead then fflush(stdout) will do the trick, i.e.
- this way Hello is guaranteed to be printed when the crash occurs.