use std::io; fn main() { let mut buffer = String::new(); let stdin = io::stdin(); let mut total = 0; loop { let input = { buffer.clear(); stdin.read_line(&mut buffer).unwrap(); buffer.trim() }; if input == "exit" { break; } let n = input.parse::().unwrap(); println!("Read: {}", n); total += n; } println!("{:?}", `(total)`); }