various: handle return values of write calls
diff --git a/testC14N.c b/testC14N.c
index fbfa869..dc1a9a6 100644
--- a/testC14N.c
+++ b/testC14N.c
@@ -104,8 +104,10 @@
 	    with_comments, &result);
     if(ret >= 0) {
 	if(result != NULL) {
-	    write(1, result, ret);
-	    xmlFree(result);          
+	    if (write(STDOUT_FILENO, result, ret) == -1) {
+		fprintf(stderr, "Can't write data\n");
+	    }
+	    xmlFree(result);
 	}
     } else {
 	fprintf(stderr,"Error: failed to canonicalize XML file \"%s\" (ret=%d)\n", xml_filename, ret);