Added writeFile function.
Fixed merge conflicts.