Hi folks

I'm working on some code that extracts data from a set of XML files 
using REXML stores this as arrays of arrays of floats (one array of 
floats per file), does some processing and then writes the results to 4 
text files for visualisation with gnuplot.

However, what happens is that although 4 files get created all the data 
gets saved in the first one to be opened. It's as if the block in 
writeMatrix() stores the reference to the first File object and uses 
that on the other 3 method invocations. If that's the case then I've 
obviously failed to understand the appropriate way to use a block.

What would be a better way to code this in ruby?

thanks

Dave

Here's a portion of the class handling writing the files.

class TuneInputData

   ... snip snip ...

  def writeData()

    writeMatrix(@@LUMINANCE_DATA_FILE, @imageVector)

    writeMatrix(@@VOICE_DATA_FILE, @voiceVector)

    writeMatrix(@@SOUND_DATA_FILE, @soundVector)

    writeMatrix(@@RHYTHM_DATA_FILE, @rhythmVector)

    writeColumn(@@COLOURFULNESS_DATA_FILE, @imageColourfulness)

  end

  def writeMatrix(filename, matrix)

    file = File.new(filename, "w")

    matrix.each { |row| writeRow(file, row) }

  end

  def writeRow(file, row) 

    outString = ""

    row.each { |v| outString = outString + v.to_s + " " }

    file.puts(outString)

  end

  ... snip snip ...

end