Added __repr__
Re-raising exception.
Using the with statement when writing files.
When reading the files with links make sure there are no duplicates.
Do not write the output file with binary.

Also use the with statement.