Creating a Reach Program

I am creating a program that does the following:
This project involves adding a method reach to all objects. The reach method is like the standard each method, except that it applies to the leaves of container objects. A leaf is just a method that does not define the each method.
It should re-open class Object and define the reach method. The body of reach checks whether the self has the each method. If not, simply yield(self); otherwise run the each method on yourself and call reach on each component, sending it a code block that simply calls yield on its argument. To find out if an object x has a particular method m, you may use x.respond_to?(m), where m is a string giving the name.
I have the following:

class String
remove_method(:each)
end

class Object
def reach &x
#checking if responds to each and if so prints it out else
# returns the objects yielded
each do |e|
x.call(e)
if(e.respond_to?(:each))
e.reach(&x)
else
yield(self)
self.each{|x| print x, "
"}
end
end
end
end

#test
[4, 13, 18, “fred”, “alice”].each { |x| print x, "
"}
[4, 13, 18, “fred”, “alice”].reach {|x| print x, "
"}
[4, [13, 88], [19, “fred”, “snark”], “alice”].each { |x| print x, "
"}
[4, [13, 88], [19, “fred”, “snark”], “alice”].reach { |x| print x, "
"}
gets #waits for user to hit enter to exit the program

I am getting an error when I run it… not sure where the error lies but please help!!