Correct version of BS
Clean up file writing