Writing result to files