Write the array data into the output file

Listing 4 writes the array data into the output file in forward order by applying the insertion operator to the file output stream object named outFile,

Note the similarity of the code in Listing 4 to the code in Listing 3.

As you can see, reading and writing data to a file isn't much different from reading data from the keyboard and writing data to the computer screen.