Fixed a bug resulting in corruption of the output file.
Fixed the mode of the source script.