change file creation and added check for testfile existence