Hi,
You only talk about ttyS0 (as far as I understand). So you either need an external feedback (Tx--> Rx) or you need two ports.
(I don´t understand what you mean with "connected internally")
The basic question is:
* is the file not SENT correctly
* or is it not RECEIVED correctly
On a real port you may use a scope to find out.
You also may use a second computer to find out.
Correct port setup is essential. Also the wiring (according the setup, like handshake signals).
Klaus