Write training data to file