Added writeFile logic. Now the output creates the overlay directory tree if missing, and creates the correct file in it.