test if fopen work

if don't work trow an error and stop the program