Source: https://www3.cs.stonybrook.edu/~cse130/130 - 08 - Advanced Input and Output.pdf