The fwriteerror() function now needs to fclose() the stream,