This is really a library specific question. Thus it would be posted to the forum for that.
And it probably requires a small code example to demonstrate the problem as well.
But your basic problem seems to be
1. You 'wrote' a file
2. You 'looked' at the file and it wasn't 'right'
3. You wrote code to 'read' the file and it was 'right' there.
Everything quoted in the above is an assumption. (There are others as well.) Examining your assumptions might demonstrate the problem (for example you did not in fact write the file or didn't write it where you think you did.)