Switched to using File.open and yield semantics for writing to be compatible with
ruby-1.8.7.