writes to an output file