Consider the following loop:
While Console.In.Peek() >= 0
Console.WriteLine(Console.ReadLine())
End While
It works as expected (i.e. echos the input) when the input is re-directed from a file. However, when the lines are typed in console, the program exits after the first line. Why does this happen and how can it be fixed? In other words, what should I write in the loop condition so that it exits only when Ctrl+Z
is typed?