Where is "output.txt"? I'm somewhat confused about your question, so I'll draw a crude block diagram.
|output.txt| <-- location?
|Input| -> |PIC16F877A| <-> |unknown microcontroller|
RS-232
Does that look right? If so, we will need to know what the 'microcontroller' mentioned in your question is.
You might also want to note that PIC16F877As (or most microcontrollers, for that matter), does not have a filesystem, or any concept of 'files': you program binary data into it.
When we've got some more info, we can help you out a little more. Something that would be really beneficial would be the goal of this particular setup... namely, what you want it to do.
P.S.: Don't cross-post.