import os target = "foobar" flErr = open(os.path.join(".", 'ft2err.txt'), 'w+') print("In newer:cannot remove ", target,"\n", file = flErr)