From: Robert Klemme Date: 2009-09-05T22:25:05+09:00 Subject: Re: End of file error when trying to Marshal.load On 05.09.2009 14:35, Vahagn Hayrapetyan wrote: > @Robert: > > Ah! "While not closing a read only file usually does not have dramatic > consequences, not closing a file opened for writing likely has dramatic > consequences." > > The working method: > > def marshalKlass > o = Klass.new("hello\n") > print o.sayHello > dumped = File.open("output.txt", "w") > Marshal.dump(o, dumped) > dumped.close > data = File.open("output.txt", "r") > obj = Marshal.load(data) > data.close > print obj.sayHello > end This is better but my point in the blog article was a different one: use the block form of File.open because it is more robust. Cheers robert -- remember.guy do |as, often| as.you_can - without end http://blog.rubybestpractices.com/