Moved low-level read/write-to-file functions into their own library.