Runaway cgi process

Got this from the guy who hosts my shell account:

24168 zem 14 0 5800 5716 580 R 49.9 1.1 659:45 upload.cgi
10636 zem 15 0 8016 7804 576 R 47.1 1.5 722:43 upload.cgi

upload.cgi was doing a runaway CPU usage thing. Not sure why. Might
want to take a look at it and see.

Couldn't figure it either - anyone?

#!/home/zem/usr/bin/ruby

# from http://www.zytrax.com/tech/lang/ruby/#upload

require 'cgi'
require 'stringio'

puts "Content-type: text/html"
puts

cgi = CGI.new

tmpfile = cgi['datafile'].path
fromfile = cgi['datafile']

# create output file reference as original filename in our chosen directory
tofile = '/home/zem/incoming/'+fromfile.original_filename
# copy the file
# note the untaint prevents a security error
# cgi sets up an StringIO object if file < 10240
# or a Tempfile object following works for both
File.open(tofile.untaint, 'w') { |file| file << fromfile.read}

puts %{
<html>
<head>
  <title>File Uploaded</title>
</head>
<body>
#{fromfile.original_filename} uploaded<br>
Size: #{fromfile.length} bytes<br>
[<a href="http://zem.novylen.net/upload.html&quot;&gt;Upload another file</a>]
[<a href="http://zem.novylen.net">Return home</a>]
</body>
}