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