Use freopen() instead of fopen() to re-assign stdin