Fix for file writing