Perhaps something like:
(
Iter.open(filename)
.tee(
# This is the second iterator, provided to a callable
lambda it: (
it
.map(str.lower)
.write_to_file("lower.txt")
)
)
# This continues with the original lines iterator
.map(str.upper)
.write_to_file("upper.txt")
)