You can read an I/O stream byte by byte with each_byte:
File.open("main.rb").each_byte { |byte| puts byte }
When reading byte by byte, you get the single byte values of each character rather than the characters themselves.
To convert into text characters, you can use the chr method.