Writing result to file