Close file after reading from it

Added test to check number of open fds.