Code generation to file working