Welcome to CodeRanch.
Since white space is important in Python, it is vital you use
Code Tags to preserve your code's formatting. I have added them to your post.
When writing a file, data may not be committed to disk as it is written due to caching at various levels (application, OS, hardware, etc.). The python method close() will flush a buffer and make sure all the data is written. Are you closing all your files?