- fwrite ( buf_out, 1, len_out, F);
- fclose(F);
+ if (!F)
+ {
+ yaz_log(YLOG_FATAL|YLOG_ERRNO, "open req.apdu failed");
+ }
+ else
+ {
+ if (fwrite ( buf_out, 1, len_out, F) != len_out)
+ yaz_log(YLOG_FATAL|YLOG_ERRNO, "write req.apdu failed");
+ if (fclose(F))
+ yaz_log(YLOG_FATAL|YLOG_ERRNO, "write req.apdu failed");
+ }