Bug fix for file opening