Check for file first and generalise