Write sensor data to a CSV file during simulation.