Add files to a gzip file

I’d like to add several separate files into a new Gzip file created
within ruby.

The code I’ve got at the moment is as follows:

File.open(‘coursework_submissions.gz’, ‘wb’) do |f|
gz = Zlib::GzipWriter.new(f)
@student_list.each do |s|
temp = File.open("#{s.student.student_no}", ‘wb’)
temp.write(s.submission)
temp.close()
gz.add(File.open("#{s.student.student_no}", ‘r’))
File.delete("#{s.student.student_no}")
end
gz.close
end

However, this just produces a file, coursework_submissions.gz,
containing a file, coursework_submissions with the text of the files I
want to add contained inside. Where am I going wrong?

Thanks everyone.