Upon successful completion 0 is returned. Otherwise, EOF is returned and
the global variable errno is set to indicate the error. In either case
any further access (including another call to fclose()) to the stream
results in undefined behaviour.
Note that fclose only flushes the user space buffers provided by the C
library. To ensure that the data is physically stored on disk the kernel
buffers must be flushed too, e.g. with sync(2) or fsync(2).