I am currently writing a little applet to modify files in a certain way. However, I am noticing wildly strange behaviour. I have an output file that is fopen'd in "a+" mode. If the file did not exist and was created, the resulting output is total garbage (however, it exhibits the expected filesize). If the file already existed, the whole program crashes on the matching call to fclose for the same file. I am using plain old standard fprintf calls to output to the file.
Can anyone help me figure out what is causing this?