added code to close sink file (aka text output)