Set error if the file buffer flushing fails on Windows

Change-Id: I58cf61540bc53e314988753a252cbc71003ce581
Reviewed-by: Sergey Belyashov <Sergey.Belyashov@gmail.com>
Reviewed-by: Denis Shienkov <denis.shienkov@gmail.com>