finally got the damn thing to write the files