When you write to a file, many times the data is actually written to a buffer and periodically the buffer is written to the file. The purpose of this is to save I/O time by writing only when the buffer gets full. Most likely, what is happening is that when your program does not stop cleanly and thus does not execute the fclose, the buffer is not getting written.
For a program like yours, you want to cause it to write the data every time, whether the buffer is full or not, because it's important to get the data into the file.
To do this, add an 'fflush()' command after your fprintf().
fprintf(fpointer,.......);
fflush(fpointer);
Note that you can use fflush on stdin and stdout also.
fflush(stdout) causes output to go immediately to stdout, rather than waiting for full buffers. I've had to do this before, but don't remember the situation that made it necessary.
fflush(stdin) flushes input buffers, so you can be sure that there are no unread characters when you prompt for new input.