Source: http://math.hawaii.edu/~dale/190/files_input_output.pdf