Modified the write and read stat functions to write/read values from the underlying stream, rather than indirectly write/read to/from a struct.
Added in the include statements for the stat struct.