Emacs/putty code help [linux]

can someone please help me with this code, I have this but it not able
to execute. can you tell what is not right or any suggestions?....Thanks

here's the initial question:
Write a statistical program in Ruby to:

a) Input the name of a data file from the command line arguments.

b) Input floating-point numbers from the data file.

c) Calculate and output the mean. This is the average, or the sum of
the
    values divided by the number of values.

d) Calculate and output the median. This is the value such than half
the
    values are larger and half are smaller. If you have an even number
of
    values use either middle value or the average of the two middle
values.

code:
puts "This program was created by Thierry NY
puts "Project 5, November 10th 2010."
puts "Program description: This is a statistical program to calculate
floating-\
      point numbers and output their mean and median.

nums = []
if ARGV[0] == nil
print "no argument detected, please enter filename."
  filename = gets.to_s.chomp
else
  filename = ARGV[0]
end

f = open filename, "r"
while x = f.gets
  nums << x.to_f
end
f.close
nums = nums.sort

count = nums.size -1
mean = 0
until count == -1
  mean = mean + nums[count]
  count = count -1
end
mean = mean/nums.size.to_f

if nums.size%2! = 0
  midindex = (nums.size-1)/2
  median = nums [midindex]
else
  midindex1 = (nums.size-1)/2
  midindex2 = (nums.size)/2
  median = (nums[midindex1] + nums[midindex2])/
end

puts "The mean is: # {mean}"
puts "The median is: # {median}"

···

--
Posted via http://www.ruby-forum.com/.

code:
puts "This program was created by Thierry NY
puts "Project 5, November 10th 2010."
puts "Program description: This is a statistical program to calculate
floating-\
      point numbers and output their mean and median.

nums =
if ARGV[0] == nil
print "no argument detected, please enter filename."
  filename = gets.to_s.chomp
else
  filename = ARGV[0]
end

f = open filename, "r"
while x = f.gets
  nums << x.to_f
end
f.close
nums = nums.sort

count = nums.size -1
mean = 0
until count == -1
  mean = mean + nums[count]
  count = count -1
end
mean = mean/nums.size.to_f

if nums.size%2! = 0
  midindex = (nums.size-1)/2
  median = nums [midindex]
else
  midindex1 = (nums.size-1)/2
  midindex2 = (nums.size)/2
  median = (nums[midindex1] + nums[midindex2])/
end

puts "The mean is: # {mean}"
puts "The median is: # {median}"

Okay, this looks like homework, but since you're not actually asking us to do it for you, I'll bite (byte?)

I'm seeing a bunch of syntax errors. You need to look at the error messages ruby is giving you and try and work out what you spelled wrong / missed out. Often the actual problem will be on the line above the one Ruby thinks the problem is on.

I'll give you the first one for free: on the second put statement, the extended line ending "median" should have a close quote.

If you get stuck again, post the error messsage and I'll try to help. (Or maybe someone else will ... it's a big list.)

···

--
It's not an optical illusion, it just looks like one.
    -- Phil White