Improved file writing.