pgm = File.read("star2.pgm") pgm = pgm.to_a[5..-1].join pgm.gsub!(/./m) { |m| if m[0] < 200 "*" else " " end } pgm.gsub!(/.{60}/, "\\&\n") puts pgm