Swap IO.write for File.open(..) { ... } (Ruby 1.9.2 compat).