File Writer Improvement

Improved writing data to files.