Check if the file we are writing to is a file.

Remove superfluous remove, since if the file exists but we
can't open it it might belong to someone else, so keep it...
Change-Id: Ic541fe134dad76983088d4b3d243d15e78f9fed4
Reviewed-by: Niels Weber <niels.weber@digia.com>