Make resample work
Error out properly if there is a file write error