Recording MIDI data to a midi file

I’m sure this is TD 101, but I need your help!

I am trying to write MIDI data created in TD to be written to a .mid file. In my efforts, I am pretty sure that has to do with the midi out chop, as it has that “write” button to be written to a file. Eventually, what I want to be able to do is take that midi file, place it in reaper, and then assign a midi instrument to it and record that, then put the audio with the video and then BOOM! Finished project!

BUT…

I can’t seem to get that function to work correctly. I’ve tried hitting the button before the recording, i’ve tried hitting the button after recording, and I’ve tried holding down the write button for a few seconds to see if it only wrote data when held down. I haven’t had any luck. Sometimes it won’t record anything. Sometimes it seems to be recording correctly, but the timing is wrong.
It’s clear that i’m doing something wrong. I have the constants (that are being generated by TD) to be sending out data in the format CxxNxx if that helps. Is there a better way to be doing this?

Thanks!!