FILEIO: Make fileio.py into a more general purpose utility with command line arguments.

Also add doc strings to python and C functions.