moved binary cp statements outside, caused issue with file being open