Only store to file when necessary