Implement freopen()