diff --git a/pdf.c b/pdf.c
index c6d7dc6cb667042436efc251a3213ae9d41e410d..e472028aff09d4ab990b2a4e65488e3b5d0169a6 100644
--- a/pdf.c
+++ b/pdf.c
@@ -2417,12 +2417,14 @@ basename(const char *fn)
 	return strdup(p);
 }
 
+#include <err.h>	/* for text_extract */
+
 /*
  * This utility extracts the text stream from the global environment
  * writes it out to a file with the same name as the pdf input filename
  * but with a .psectxt suffix.
  */
-int
+void
 text_extract(struct Env *aux)
 {
 
@@ -2450,10 +2452,8 @@ text_extract(struct Env *aux)
 	int namelen = outdlen + infnlen + sfxlen;
 
 	char *outfn = (char *) malloc(sizeof(char) * namelen+1);
-	if (outfn == NULL) {
-		//fprintf(stderr, "text_extract:: malloc() failed");
-		return errno;
-	}
+	if (outfn == NULL)
+		err(1, "text_extract: malloc 1");
 	memcpy(outfn, outdir, outdlen);
 	memcpy(&outfn[outdlen], fn, infnlen);
 	memcpy(&outfn[outdlen+infnlen], ".psectxt", sfxlen);
@@ -2461,18 +2461,13 @@ text_extract(struct Env *aux)
 
 	// open the file for writing
 	FILE *stream;
-	if (!(stream = fopen(outfn, "w"))) {
-		//fprintf(stderr,
-		//		"text_extract:: Failed to open file '%s' for writing\n", outfn);
-		return errno;
-	}
+	if (!(stream = fopen(outfn, "w")))
+		err(1, "%s", outfn);
 
 	// DEBUG
 	char *outfn2 = (char *) malloc(sizeof(char) * namelen+1);
-	if (outfn2 == NULL) {
-		//fprintf(stderr, "text_extract:: malloc() failed");
-		return errno;
-	}
+	if (outfn2 == NULL)
+		err(1, "text_extract: malloc 2");
 	sfxlen = strlen(".strtxt");
 	namelen = outdlen + infnlen + sfxlen;
 
@@ -2482,11 +2477,8 @@ text_extract(struct Env *aux)
 	outfn2[namelen] = '\0'; // null terminate the string
 	// open the file for writing
 	FILE *stream2;
-	if (!(stream2 = fopen(outfn2, "w"))) {
-		//fprintf(stderr,
-		//		"text_extract:: Failed to open file '%s' for writing\n", outfn);
-		return errno;
-	}
+	if (!(stream2 = fopen(outfn2, "w")))
+		err(1, "%s", outfn2);
 	// DEBUG
 
 	struct textnode *curr = aux->txthead;
@@ -2539,7 +2531,6 @@ text_extract(struct Env *aux)
 	free(outfn);
 	free(outfn2);
 	free(fn);
-	return 0;
 }
 
 
@@ -6149,11 +6140,8 @@ main(int argc, char *argv[])
 	h_pprintln(stdout, res->ast);
 
 	/* Save the extracted text */
-	if (aux.ntextobjs > 0) {
-		int ecode = text_extract(&aux);
-		if (ecode)
-			return (ecode);
-	}
+	if (aux.ntextobjs > 0)
+		text_extract(&aux);
 
 	/* Print errors to stderr */
 	print_log_messages();