corrected some #includes
check return value of freopen()