writing payload to file