The only way you're going to get the file interpreted is by feeding it to the server, so yes, a temporary file is a must - whether you put the search results in a file and include it in the templated page (search.php?myhash, where file is named according to myhash) or include the templated page as multiple pieces around the search results (include header.php and footer.php).