fn main() { if std::env::args().len() != 2 { eprintln!("usage: popline \n"); eprintln!("removes the first line of a file and rewrites it to disk without that line"); std::process::exit(1); } let file = std::path::PathBuf::from(std::env::args().nth(1).unwrap()); let string = std::fs::read_to_string(&file).unwrap(); let mut lines = string.lines(); let line = match lines.next() { None => { std::process::exit(1); } Some(line) => line, }; let write = lines.collect::>().join("\n"); std::fs::write(file, write).unwrap(); println!("{line}"); }