Respect file permissions, if readonly

Fixes issue #145
Use unless
Merge pull request #603 from siddhanathan/pull

Respect file permissions, if readonly