From: Vahagn Hayrapetyan Date: 2009-09-05T20:20:06+09:00 Subject: End of file error when trying to Marshal.load Hi,- I am trying out the marshaling functionality of Ruby with this documentation as a guide: http://www.ruby-doc.org/core/classes/Marshal.html Code goes like this: ***************************** class Klass def initialize(str) @str = str end def sayHello @str end end def marshalKlass o = Klass.new("hello\n") print o.sayHello Marshal.dump(o, File.open("output.txt", "w")) data = File.open("output.txt") # all fine up until here obj = Marshal.load(data) # EOFError print obj.sayHello end if __FILE__ == $PROGRAM_NAME marshalKlass end ***************************** The line: obj = Marshal.load(data) gives the following error: Klass.rb:19:in `load': end of file reached (EOFError) from Klass.rb:19:in `marshalKlass' from Klass.rb:32 The line: data = File.open("output.txt") places the cursor at the start of the file. What's wrong? Thanks! / Vahagn -- Posted via http://www.ruby-forum.com/.