Removed function write-file!.
Cleaned up the code.