rewrite the testfile creation to use open instead of fopen