Index: /tools/ListenToArduino/main.c
===================================================================
--- /tools/ListenToArduino/main.c	(revision 103)
+++ /tools/ListenToArduino/main.c	(revision 104)
@@ -117,7 +117,5 @@
 
 	FILE *outfile;
-	outfile = openOutfile(myPath);
-	
-	if (outfile == NULL) {return -1;}	
+	
 
 	char outstring[400];
@@ -133,5 +131,9 @@
             buf[res]=0;             /* set end of string, so we can printf */
 	
-	    if (strncmp (buf,"[Temp,",6) != 0) continue;
+	    
+		if (strncmp (buf,"[Temp,",6) != 0) continue;
+
+		outfile = openOutfile(myPath);
+		if (outfile == NULL) {return -1;}	
 		
 		time_t rawtime;
@@ -160,4 +162,5 @@
             fprintf(outfile, "%s", outstring);
 	    fflush(outfile);		
+	fclose(outfile);
         
 	if (poll_stdin_time(1500000)==1) {
@@ -172,5 +175,4 @@
 	/* restore the old port settings */
         tcsetattr(fd,TCSANOW,&oldtio);
-	fclose(outfile);
 
 return 0;
