--- loncom/xml/londefdef.pm	2010/08/16 15:56:08	1.421
+++ loncom/xml/londefdef.pm	2010/10/19 19:33:21	1.424
@@ -1,7 +1,7 @@
 # The LearningOnline Network with CAPA
 # Tags Default Definition Module 
 #
-# $Id: londefdef.pm,v 1.421 2010/08/16 15:56:08 raeburn Exp $
+# $Id: londefdef.pm,v 1.424 2010/10/19 19:33:21 raeburn Exp $
 # 
 #
 # Copyright Michigan State University Board of Trustees
@@ -43,7 +43,6 @@ use Apache::lonnet;
 use strict;
 use Apache::lonxml;
 use Apache::lontable;
-use Apache::File();
 use Image::Magick;
 use Apache::lonmenu();
 use Apache::lonmeta();
@@ -2193,7 +2192,9 @@ sub end_table {
 
 	my $table = pop(@Apache::londefdef::table);
 	my $t     = $table->generate();
+	# &Apache::lonnet::logthis("Generating string");
 	$currentstring = $t->generate_string();
+	# &Apache::lonnet::logthis("Generated: $currentstring");
 	&enable_para();
 	#--------------------------------------------------------------
 	#  Old table code:
@@ -4614,13 +4615,13 @@ sub get_eps_image {
 
 		#if replication failed try to produce eps file dynamically
 		$src=~s/\.ps$/\.eps/;
-		my $temp_file;
-		open(FILE,">>/home/httpd/prtspool/$env{'user.name'}_$env{'user.domain'}_printout.dat");
-		my $newsrc=$orig_src;
-		$newsrc =~ s|(.*)/res/|/home/httpd/html/res/|;
-		&Apache::lonxml::debug("queueing $newsrc for dynamic eps production.");
-		print FILE ("$newsrc\n");
-		close(FILE);
+		if (open(FILE,">>/home/httpd/prtspool/$env{'user.name'}_$env{'user.domain'}_printout.dat")) {
+		    my $newsrc=$orig_src;
+		    $newsrc =~ s|(.*)/res/|/home/httpd/html/res/|;
+		    &Apache::lonxml::debug("queueing $newsrc for dynamic eps production.");
+		    print FILE ("$newsrc\n");
+		    close(FILE);
+                }
 		$src=~s|/home/httpd/html/res|/home/httpd/prtspool|;
 		$src=~s|/home/([^/]*)/public_html/|/home/httpd/prtspool/$1/|;
 		if ($sext ne "") {	 # Put the ext. back in to uniquify.
@@ -4653,8 +4654,10 @@ sub get_eps_image {
 sub eps_generation {
     my ($src,$file,$width_param) = @_;	     
     my $filename = "/home/httpd/prtspool/$env{'user.name'}_$env{'user.domain'}_printout.dat";
-    my $temp_file = Apache::File->new('>>'.$filename); 
-    print $temp_file "$src\n";
+    if (open(my $tmpfile,">>$filename")) { 
+        print $tmpfile "$src\n";
+        close($tmpfile);
+    }
     my $newsrc = $src;
     $newsrc =~ s/(\.bmp|\.gif|\.jpg|\.jpeg)$/\.eps/i;
     $newsrc=~s{/home/httpd/html/res}{};