Improved file saving