To expand on
elef's explanation, writing to files is usually buffered, that means that data is written to disk only after a specific amount of data has beeen collected. Or after the files is closed, because then it is obvious that no further data will arrive.