<commit_before>use std::io;
use std::io::Write;

fn write(out: &str) {
    print!("{}", out);
    io::stdout().flush().unwrap_or(());
}

pub fn repl() {
    loop {
        let mut input = String::new();
        write("> ");

        let read_bytes = io::stdin().read_line(&mut input)
            .ok()
            .expect("Failed to read line!");

        if read_bytes == 0 {
            println!("\nExiting...");
            break;
        }

        write(&input);
    }
}<commit_msg>better error handling<commit_after>use std::io;
use std::io::Write;

fn write(out: &str) {
    print!("{}", out);
    match io::stdout().flush() {
        Ok(u)  => u,
        Err(e) => println!("Failed to flush stdout: {}", e),
    };
}

pub fn repl() {
    let mut input = String::new();

    loop {
        write("> ");

        input.clear();
        let bytes_read = match io::stdin().read_line(&mut input) {
            Ok(b)  => b,
            Err(e) => { println!("Failed to read stdin: {}", e); 0 },
        };

        if bytes_read == 0 {
            println!("\nExiting...");
            break;
        }

        write(&input);
    }
}
{'fraction_non_alphanumeric': 0.19823788546255505, 'fraction_numerical': 0.0026431718061674008, 'mean_word_length': 1.8049382716049382, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 9, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '5783034', 'n_tokens_mistral': 379, 'n_tokens_neox': 371, 'n_words': 85}