Add fopen wrapper and update samples.