f_in = File::open("data2.txt", "r") out = File::open("out2.txt", "w") while (!f_in.eof?) if f_in.gets.strip == "All Your Base" out << "Are Belong To Us\n" else out << "ZIG\n" end end f_in.close out.close