Hi,
just don't use the pipeline groovy code for that , use suitable external tools (e.g. cat and shell pipes)
sh ``` cat part1 > file; cat part2 >> file ```
[1] has a recommendation:
In general try to fit the tool to the job. Consider writing short Shell/Batch/Groovy/Python scripts when running a complex process using a build agent. Good examples include processing data, communicating interactively with REST APIs, and parsing/templating larger XML or JSON files. The sh and bat steps are helpful to invoke these, especially with returnStdout: true to return the output from this script and save it as a variable (Scripted Pipeline).
The Pipeline DSL is not designed for arbitrary networking and computation tasks - it is intended for CI/CD scripting.
Björn