write method to outfile