filename = 'truncate.txt'f = open(filename, 'w') do |f| f << 'this is a test.'endFile.size(filename) File.truncate(filename, 30)File.size(filename) open(filename) { |f| f.read }