assign filehead as NULL when declare
do not free allocated memory before exit