use std::fs::File;
      use std::io::{Write, BufReader, BufRead, Error};
      
      fn main() -> Result<(), Error> {
        let path = "lines.txt";
        let mut output = File::create(path)?;
        write!(output, "Rust Fun")?;
        let input = File::open(path)?;
        let buffered = BufReader::new(input);
        for line in buffered.lines() {
          println!("{}", line?);
        }
        Ok(())
      }
      
      Rust language logo

      Read lines from a file

      Codiga's Rust Recipes

      print them in terminal

      0 Comments

        Add Comment

        Log in to add a comment

        Codiga - All rights reserved 2022.