Use ostream instead of ofstream in mapper