diff --git a/ffmpeg.c b/ffmpeg.c
index 5e9fcf197c4e14cc91f9d08ba5962f4758e2556a..b290022d02f40f9c6e29e291f277a93eb42343f1 100644
--- a/ffmpeg.c
+++ b/ffmpeg.c
@@ -611,11 +611,13 @@ static int read_key(void)
 
 static int read_yn(void)
 {
-    int c;
+    int c, t;
 #if HAVE_TERMIOS_H || HAVE_KBHIT
     while((c=read_key()) < 0);
 #else
-    c= getchar();
+    t=c= getchar();
+    while (t != '\n' && t != EOF)
+        t = getchar();
 #endif
 
     return (toupper(c) == 'Y');