def reopen_io(io, path, mode = nil)
      begin
        if mode
          io.reopen(path, mode)
        else
          io.reopen(path)
        end
        io.binmode
      rescue ::Exception
      end
    end
def reopen_io(io, path, mode = nil)
      begin
        if mode
          io.reopen(path, mode)
        else
          io.reopen(path)
        end
        io.binmode
      rescue ::Exception
      end
    end
Attempts to reopen an IO object.