From: Paul Brannan Date: 2002-05-09T03:42:30+09:00 Subject: gets and eof? I have a program that reads input from a socket and displays output on the terminal. It exits on end of file. The loop looks something like: loop do break if $stdin.eof? line = $stdin.gets puts "<-- #{line}" end However, when I first wrote it, I instead wrote: loop do line = $stdin.gets break if $stdin.eof? puts "<-- #{line}" end The first case works correctly. The second case does not; when I type a line, it doesn't show up until the second line is typed. This happens whether I am using $stdin or whether I am using a socket (returned by TCPServer#accept). Why does this happen in the second case? Paul