output total amount of frames sent at end, exit when reading from stdin and stdin is closed