O_BINARY resulted in strange behaviour, changed to fopen/fread/fwrite
instead