Writing output function.