Implement newFile command
Fix shouldClose for files