fixed fwrite() issue