Put the transform task definition in front of your each loop.
You only create the task inside this loop.

task :transform do
end

my_files.each do |file|
  file ...
  task :transform => file
end
next_file = 'transformed_files.txt'
file next_file => :transform do
# Do something with all transformed files to produce 1 output file
end