Added error messages in case something goes wrong.
Added more messages.
Improved temp-file naming pattern.
Added check if the output file exists already.