Move formatted file writing to module

We will want to use this from other Rust-generating modules.
diff --git a/codegen/src/main.rs b/codegen/src/main.rs
index d29a28c..01c3ec0 100644
--- a/codegen/src/main.rs
+++ b/codegen/src/main.rs
@@ -12,6 +12,7 @@
 #![recursion_limit = "128"]
 #![allow(clippy::needless_pass_by_value)]
 
+mod file;
 mod gen;
 mod json;
 mod parse;