this actually does the same thing as end for a file a stream. I suggest calling end and the fs.closeSync on the file descriptor as end doesn't close the file descriptor