Generate file from gear

Instead of just printing, it writes to a file