File I/O in Ruby

Watch out! This tutorial is over 7 years old. Please keep this in mind as some code snippets provided may no longer work or need modification to work on current systems.

This version opens a file for writing, and writes its output to a file selected by the user. The second argument to open is the same as the second argument to a plain C fopen, except it will default to reading.

The object returned from open is class File.

Continue reading