<SYSTEM_TASK:>
Solve the following problem using Python, implementing the functions described below, one line at a time
<END_TASK>
<USER_TASK:>
Description:
 def record_message(self, msg, from_rewarder):
 """Record a message to our rewards.demo file if it is has been opened"""

        if self.file:
            # Include an authoritative timestamp (because the `sent_at` from the server is likely to be different
            timestamped_message = {
                'timestamp': time.time(),
                'message': json.loads(msg),
                'from_rewarder': from_rewarder,
            }
            self.file.write(json.dumps(timestamped_message))
            self.file.write('\n')
            self.file.flush()