Fixing bug that was causing file writing to fail.