Quick and dirty middleware that writes to file