This source code is an excerpt of a function which simulates the Game of Life. I'm trying to write the contents of the game grid to a file.
fn populate_to_file(filename: &String, world: [[u8; 75]; 75]) {
let path = std::fs::File::create(filename);
for i in 0..74 {
for j in 0..74 {
if world[i][j] == 1 {
let x_str = String::from(i.to_string());
let y_str = String::from(j.to_string());
fs::write(filename, x_str + &" ".to_string()).expect("Failed to write to file!");
fs::write(filename, y_str).expect("Failed to write to file!");
}
}
}
}