fixed file io and deleted file after test