check files, include more

Check for files before it writes and include files in for loop