Add some more code to bmfs_file_write