Use fgets_unlocked instead of fgets.