moving delete file to after it's read