Corrected the check_density.py script so that it does not lose the output from magic before attempting to process it.