Add optimizations for File.write operation in 'generate_file' function