added test to exit when stdin is closed