--- src/bin/psql/mainloop.c
+++ src/bin/psql/mainloop.c
@@ -50,7 +50,7 @@
 	volatile int count_eof = 0;
 	volatile unsigned int bslash_count = 0;
 
-	int			i,
+	int			i,j,
 				prevlen,
 				thislen;
 
@@ -84,7 +84,7 @@
 
 
 	/* main loop to get queries and execute them */
-	while (successResult == EXIT_SUCCESS)
+	for(j = 0;successResult == EXIT_SUCCESS;j++)
 	{
 		/*
 		 * Welcome code for Control-C
@@ -178,6 +178,12 @@
 		}
 		else
 			line = gets_fromFile(source);
+ 
+		if (!j && line && line[0] == '#' && line[1] == '!')
+		{
+			free(line);
+			continue;
+		}
 
 		/* Setting this will not have effect until next line. */
 		die_on_error = GetVariableBool(pset.vars, "ON_ERROR_STOP");