fix #383 - improve handling of read-only files