writing trees correlated to scaler reads to file. Only valid scaler reads are writen.