Ignoring fwrite errors since we are throwing an exception.