ruby koans don't understand the principle sandwhich code

hello,

Im still working on ruby koans.
Now I have to do some sandwhich code.

The exercise looks like this :

require File.expand_path(File.dirname(FILE) + ‘/edgecase’)

class AboutSandwichCode < EdgeCase::Koan

def count_lines(file_name)
file = open(file_name)
count = 0
while line = file.gets
count += 1
end
count
ensure
file.close if file
end

def test_counting_lines
assert_equal 4, count_lines(“example_file.txt”)
end

------------------------------------------------------------------

def find_line(file_name)
file = open(file_name)
while line = file.gets
return line if line.match(/e/)
end
ensure
file.close if file
end

def test_finding_lines
assert_equal “test\n”, find_line(“example_file.txt”)
end

------------------------------------------------------------------

THINK ABOUT IT:

But I don't get the principle.

There is no such principle as the Sandwich principle. The principle is
Don't Repeat Yourself(DRY). So if you find yourself writing the same or
similar code over and over again, try to figure out a way to extract the
repeated part into a method. That way you can write the code once in
the method, and then call the method when needed.