Fix TRC file writing