opens text.txt for reading and writing, and changes the first character of the first line to X.
f = File.open("text.txt", "r+") f.write "123456" f.close