diff --git a/src/bin/pg_basebackup/receivelog.c b/src/bin/pg_basebackup/receivelog.c
index 1b8a5ad15ce74f269e9082008607c824dbac2f4b..f0f8760e2dbc81d3fcb2e55e333301e85fc4750e 100644
--- a/src/bin/pg_basebackup/receivelog.c
+++ b/src/bin/pg_basebackup/receivelog.c
@@ -1021,7 +1021,7 @@ ProcessKeepaliveMsg(PGconn *conn, char *copybuf, int len,
 	if (replyRequested && still_sending)
 	{
 		if (reportFlushPosition && lastFlushPosition < blockpos &&
-			walfile != 1)
+			walfile != -1)
 		{
 			/*
 			 * If a valid flush location needs to be reported,