Rust program, which reads, processes, and writes a file
This is my first post here, but I thought I might give this one a shot. 


Your code could be made more user friendly by providing custom error messages.


When you get the filename from the command line arguments, you assume that the user will provide at least one command line argument. You could provide a helpful error message if they don't. 
If opening a file fails for some reason (probably that the file doesn't exist at all), you could provide a custom print-out.  
My example uses expect() as an example, but in code where user-friendliness is actually a goal, you would probably want to use eprintln!("error message here") and std::process::exit(1) to quit the program. That way, you don't get rust's extra panic messages which a user shouldn't have to understand. 

You don't actually have to allocate a Vec to read the command line arguments, you can use the .nth method on the Args iterator. 
You don't need the trim() call, because the lines() iterator already removes the newlines. 
If you are looking to make the code cleaner, you could open the file for reading with File::open, and open it for writing with File::create.
I don't know how to significantly improve the performance of your code.


The biggest thing that I notice is that when you write the processed sequence of numbers to the file, you call write! on every line. This means that you talk to the OS every time you write a number. This could be made faster by using BufWriter, which would let you talk to the file only once. Alternatively, you could construct your output string while you are reading the file.



use std::env;
use std::fs::File;
use std::io::{BufReader, BufRead};
use std::io::Write;

fn main() {
    let file_path = &amp;env::args().nth(1).expect("must provide an input file");

    let file = File::open(file_path).expect("failed to open input file");

    let doubled_contents: String = BufReader::new(file).lines()
        .map(|line| {
            let number = line.unwrap().parse::&lt;i32&gt;().expect("failed to parse file");
            format!("{}\n", number*2)
        })
        .collect();

    let mut output_file = File::create(file_path).expect("failed to open output file");
    write!(output_file, "{}", doubled_contents).expect("could not write output");
}