Index: /usr/src/Padre/Padre/lib/Padre/Wx/Main.pm
===================================================================
--- /usr/src/Padre/Padre/lib/Padre/Wx/Main.pm	(revision 19172)
+++ /usr/src/Padre/Padre/lib/Padre/Wx/Main.pm	(working copy)
@@ -2950,9 +2950,10 @@
 			# tome
 			my $pwd = $self->current->document->project_dir();
 			$cmd =~ s/"/\\"/g;
+
 			# Applescript can throw spurious errors on STDERR: http://helpx.adobe.com/photoshop/kb/unit-type-conversion-error-applescript.html
-			system qq(osascript -e 'tell app "Terminal"\n\tdo script "cd $pwd; clear; $cmd;"\nend tell'\n); 
- 	
+			system qq(osascript -e 'tell app "Terminal"\n\tdo script "cd $pwd; clear; $cmd;"\nend tell'\n);
+
 		} else {
 			system qq(xterm -sb -e "$cmd; sleep 1000" &);
 		}
@@ -4588,6 +4589,25 @@
 	# Capture where we are in the document
 	my $line = $editor->LineFromPosition( $editor->GetCurrentPos );
 
+	#if file dose not exsit close the tab
+	print "processing file called $document->{filename}\n";
+	unless ( -e $document->{filename} ) {
+		my @labels = $self->current->notebook->labels;
+		for ( 0 .. $#labels ) {
+
+			# find tab index and delete tab
+			if ( $labels[$_][1] eq $document->{filename} ) {
+				print "file names $labels[$_][1]\n";
+				print "tab index $_\n";
+
+				$self->delete($_);
+				# $self->notebook->DeletePage($_);
+			}
+		}
+
+		print "did we delete file\n";
+	}
+
 	# Reload the document and propogate to the editor
 	unless ( $document->reload ) {
 		$self->error(
@@ -4598,6 +4618,7 @@
 		);
 		return 0;
 	}
+
 	$editor->set_document($document);
 
 	# Restore the line position
@@ -4614,6 +4635,7 @@
 		return;
 	}
 
+
 	# Refresh the editor title to remove any unsaved marker
 	$editor->refresh_notebook;
 