Read before writing glue file
This fixes the process when base and target dir are the same
and thus in and output file are the same