I noticed cat test.cpp results nothing so must have been not written. I flushed and closed the temp file and it worked.