Correct fix for std file handle closing issue.