detectEOI now fills a buffer, then writes incoming data to a file