Replaced the output stream redirection and reading with a custom output
stream that writes the data directly to the desired location