Smarter file saving