f_in = File::open("data3.txt", "r") out = File::open("out3.txt", "w") while (!f_in.eof?) num = f_in.gets.strip.to_i t = 0 # build up while (t < num) t = t + 1 out << "*"*t + "\n" end # build down t = num - 1 while (t > 0) out << "*"*t + "\n" t = t - 1 end end f_in.close out.close