Fix #1495 - Infinite loop on 'wx' on read-only files