Fixed access denied error when file is readonly