There are a couple of cases it does not handle - such as cin reaching end of file (it can happen - it is possible to run your program with its input coming from a finite source such as a file or the output of another program), nor does it handle cout failing (it is also possible to run your program with its output connected to a file or another program, and this might fail, e.g. the disk becomes