Fix some build errors, add missing rewind of file being erased.