If you don't have any control over the external file, then this: <https://github.com/iamnoah/writeCapture/tree/writeCapture2> ... works like a charm. :)