File Directory Ruby

f = open('binary', 'rb+')
f.read                                    
f.pos = 2
f.write('Hello.')
f.rewind
f.read                                    
f << 'Goodbye.'
f.rewind
f.read                                    
f.close